Job manipulation

Users manipulate jobs in different ways, after a job has been submitted. It can be suspended, resumed, killed, or sent arbitrary signal jobs.

All applications that manipulate jobs are subject to authentication provisions.

Send a signal to a job

Users can send signals to submitted jobs. If the job has not been started, you can send KILL, TERM, INT, and STOP signals. These signals cause the job to be cancelled (KILL, TERM, INT) or suspended (STOP). If the job has already started, then any signal can be sent to the job.

lsb_signaljob()

lsb_signaljob() sends a signal to a job:

int lsb_signaljob(jobId, sigValue);
LS_LONG_INT  jobId;          Select job with the given job Id
int sigValue;                Signal sent to the job

The jobId and sigValue parameters are self-explanatory.

Example

The following example takes a job ID as the argument and sends a SIGSTOP signal to the job.

/******************************************************

* LSBLIB -- Examples

*

* simple bstop

* The program takes a job ID as the argument and sends a * SIGSTOP signal to the job

******************************************************/

#include <stdio.h>
#include <lsf/lsbatch.h>
#include <stdlib.h>
#include <signal.h>
int main(int argc, char **argv)
{
    /* check if input is in the right format: "simbstop JOBID" */
    if (argc != 2) {
        printf("Usage: %s jobId\n", argv[0]);
        exit(-1);
    }
    /* initialize LSBLIB and get the configuration environment */
    if (lsb_init(argv[0]) < 0) {
        lsb_perror("lsb_init");
        exit(-1);
    }
    /* send the SIGSTOP signal and check if lsb_signaljob()
    runs successfully */
    if (lsb_signaljob(atoi(argv[1]), SIGSTOP) <0) {
        lsb_perror("lsb_signaljob");
        exit(-1);
    }
    printf("Job %s is signaled\n", argv[1]);
    exit(0);
    } 

On success, the function returns 0. On failure, it returns -1 and sets lsberrno to indicate the error.