pbs_selstat(3B)

NAME
pbs_selstat - obtain status of selected PBS batch jobs

SYNOPSIS
#include <pbs_error.h>
#include <pbs_ifl.h>

struct batch_status *pbs_selstat(int connect, struct attropl *sel_list, struct attrl *rattrib, char *extend)

void pbs_statfree(struct batch_status *psj)

DESCRIPTION
Issue a batch request to examine the status of jobs which meet certain criteria. pbs_selstat() returns a list of batch_status structures for those jobs which met the selection criteria.

The sel_list struct holds the selection criteria. The rattrib struct holds the list of attributes whose values are to be returned.

This function is a combination of pbs_selectjob() and pbs_statjob(). It is an extension to the POSIX Batch standard.

Initially all batch jobs are selected for which the user is authorized to query status. This set may be reduced or filtered by specifying certain attributes of the jobs.

A Select Status batch request is generated and sent to the server over the connection specified by connect which is the return value of pbs_connect().

The parameter, sel_list , is a pointer to an attropl structure which is defined in pbs_ifl.h as:

    struct attropl {
        struct attropl *next;
        char           *name;
        char           *resource;
        char           *value;
        enum batch_op   op;
    };

The sel_list list is terminated by the first entry where next is a null pointer.

The name member points to a string which is the name of the attribute. Not all of the job attributes may be used as a selection criteria. The resource member points to a string which is the name of a resource. This member is only used when name is set to ATTR_l, otherwise it should be a pointer to a null string. The value member points to a string which is the value of the attribute or resource. The attribute names are listed in pbs_job_attributes.7B.

The op member defines the operator in the logical expression:
value operator current_value
The logical expression must evaluate as true for the job to be selected. The permissible values of op are defined in pbs_ifl.h as:
    enum batch_op { ..., EQ, NE, GE, GT, LE, LT, ... }; .
The attributes marked with (E) in the description above may only be selected with the equal, EQ, or not equal, NE, operators.

If sel_list itself is a null pointer, then no selection is done on the basis of attributes.

The parameter, rattrib , is a pointer to an attrl structure which is defined below. The rattrib list is terminated by the first entry where next is a null pointer. If attrib is given, then only the attributes in the list are returned by the server. Otherwise, all the attributes of a job are returned. When an attrib list is specified, the name member is a pointer to a attribute name as listed in pbs_alter(3) and pbs_submit(3). The resource member is only used if the name member is ATTR_l, otherwise it should be a pointer to a null string. The value member should always be a pointer to a null string.

The return value is a pointer to a list of batch_status structures or the null pointer if no jobs can be queried for status. The batch_status structure is defined in pbs_ifl.h as

    struct batch_status {
        struct batch_status *next;
        char                *name;
        struct attrl        *attribs;
        char                *text;
    }

The entry, attribs , is a pointer to a list of attrl structures defined in pbs_ifl.h as:

    struct attrl {
        struct attrl *next;
        char         *name;
        char         *resource;
        char         *value;
    };

It is up the user to free the list of batch_status structures when no longer needed, by calling pbs_statfree().

The extend parameter is for optional features and or additions. Normally, this should be null pointer.

Finished and Moved Jobs
In order to get information on finished and moved jobs, you must add an 'x' character to the extend parameter. The extend parameter is a character string; set one character to be the 'x' character. For example:
    pbs_selstat ( ..., ..., ..., extend) ...

To get information on finished and moved jobs only, specify the Finished ('F') and moved ('M') job states. You must also use the extend character string containing the 'x' character. For example:
    sel_list->next = sel_list;
    sel_list->name = ATTR_state;
    sel_list->value = "MF";
    sel_list->op = EQ;
    pbs_selstat ( ..., sel_list, ..., extend) ...

Subjobs are not considered finished until the parent array job is finished.

SEE ALSO
qselect(1B), pbs_alterjob(3B), pbs_connect(3B), pbs_statjob(3B), and pbs_selectjob(3B).

DIAGNOSTICS
When the batch request generated by pbs_selstat() function has been completed successfully by a batch server, the routine will return a pointer to the list of batch_status structures. If no jobs met the criteria or an error occurred, the return will be the null pointer. If an error occurred, the global integer pbs_errno will be set to a non-zero value.