Determine why job is suspended

It is frequently desirable to know the reasons why jobs are in a certain status. LSBLIB provides a function to print such information. This section describes a routine that prints out why a job is in suspending status.

lsb_suspreason()

When lsb_readjobinfo() reads a record of a pending job, the variables reasons and subreasons contained in the returned struct jobInfoEnt call lsb_suspreason(). This gets the reason text explaining why the job is still in pending state:

char *lsb_suspreason(reasons, subReasons, ld);

where reasons and subReasons are integer reason flags as returned by a lsb_readjobinfo() function while ld is a pointer to the following data structure:

struct loadIndexLog {
    int  nIdx;             Number of load indices configured for the
                               LSF cluster
    char **name;           List of the load index names
};

Call the below initialization and code fragment after lsb_readjobinfo() is called.

/* initialization */
struct loadIndexLog *indices =(struct loadIndexLog *)malloc
(sizeof(struct loadIndexLog));
char *suspreason;
/* get the list of all load index names */
indices->name = getindexlist(&indices->nIdx);
/* get and print out the suspended reason */
suspreason = lsb_suspreason(job->reasons,job-> subreasons,indices);
printf("%s\n",suspreason);