-
Notifications
You must be signed in to change notification settings - Fork 1
Job C Functions
job_sethid - set hid for new job IDs
#include <job.h>
int job_sethid( unsigned int hid );
The job_sethid library call is part of the job library that allows
processes to manipulate and obtain status about linux jobs. When the job
library is to be used, the job.h header file should be included to
obtain the proper definitions.
job_sethid is used to set the hid value that is used has the upper 32
bits of new job IDs. If this does not get set, then the jids upper 32
bits will be set to 0. The hid is typically used in a cluster
environment.
Upon successful completion, job_sethid returns a value of 0. Otherwise, a value of -1 is returned and errno is set to indicate the error.
job\_detachjid - detach all the processes from a job
#include <job.h>
int job_detachjid( jid_t jid );
The job_detachjid library call is part of the job library that allows
processes to manipulate and obtain status about linux jobs. When the job
library is to be used, the job.h header file should be included to
obtain the proper definitions.
job_detachjid will detach all the processes from a job, but allows the
processes to continue running. You need CAP_SYS_RESOURCE capability
for this to succeed. Since all processes will be detached, the job will
exit.
Upon successful completion, job_detachjid returns a count of the number of processes detached from the job. Otherwise, a value of -1 is returned and errno is set to indicate the error.
job\_getuid - get the user ID of a job
#include <job.h>
uid_t job_getuid( jid_t jid );
The job_getuid library call is part of the job library that allows
processes to manipulate and obtain status about linux jobs. When the job
library is to be used, the job.h header file should be included to
obtain the proper definitions.
job_getuid returns the owner (User ID) of a job.
Upon successful completion, job_getuid returns the uid of the job specified. Otherwise, a value of -1 is returned and errno is set to indicate the error.
job\_getjid - return the job ID for the given process
#include <job.h>
jid_t job_getjid( pid_t pid );
The job_getjid library call is part of the job library that allows
processes to manipulate and obtain status about linux jobs. When the job
library is to be used, the job.h header file should be included to
obtain the proper definitions.
job_getjid will return the job ID for the given process if it is part
of a job.
Upon successful completion, job_getjid returns the job ID for the
specified process. Otherwise, a value of (jid_t)-1 is returned for the
following conditions:
Communication with the job daemon fails; errno is unchanged.
The given PID is invalid; errno is set to ESRCH.
The process is not part of a job; errno is set to ENODATA.
Note that you need to test for -1 using a cast. See the [job_create] man page for an example.
job_attachpid - attach a process to a requested job
#include <job.h>
jid_t job_attachpid( pid_t pid, jid_t jid_requested );
The job_attachpid library call is part of the job library that allows
processes to manipulate and obtain status about linux jobs. When the job
library is to be used, the job.h header file should be included to
obtain the proper definitions.
job_attachpid will attach a process to a requested job if that
attaching process currently does not belong to any job and the requested
job with jid_request exists. You need CAP_SYS_RESOURCE capability for
this to succeed.
Upon successful completion, job_attachpid returns the jid_requested. Otherwise, a value of (jid_t)-1 is returned and errno is set to indicate the error. Note that you need to test for -1 using a cast. See the [job_create] man page for an example.
job_killjid - send a signal to all processes in a job
#include <job.h>
int job_killjid( jid_t jid, int sig );
The job_killjid library call is part of the job library that allows
processes to manipulate and obtain status about linux jobs. When the job
library is to be used, the job.h header file should be included to
obtain the proper definitions.
job_killjid will send a signal to all processes in the specified job.
Upon successful completion, job_killjid returns a value of 0. Otherwise, a value of -1 is returned and errno is set to indicate the error.
job_getpidlist - get the list of process pids attached to a job
#include <job.h>
int job_getpidlist( jid_t jid, pid_t *pid, int bufsize );
The job_getpidlist library call is part of the job library that allows
processes to manipulate and obtain status about linux jobs. When the job
library is to be used, the job.h header file should be included to
obtain the proper definitions.
job_getpidlist returns a list of process pids attached to a specified
job. The list of process pid values is returned in the array pointed to
by the pid argument. The caller is responsible for allocating and
freeing the memory for the array pointed to by pid. The return value
is the number of pid values that were inserted into the array.
Note that bufsize is in bytes.
Upon successful completion, job_getpidlist returns a count of the number of pids returned in the pid array. Otherwise, a value of -1 is returned and errno is set to indicate the error.
job_getprimepid - get the prime process pid for a job
#include <job.h>
pid_t job_getprimepid( jid_t jid );
The job_getprimepid library call is part of the job library that
allows processes to manipulate and obtain status about linux jobs. When
the job library is to be used, the job.h header file should be
included to obtain the proper definitions.
job_getprimepid returns the prime (oldest) process pid for a job.
Upon successful completion, job_getprimepid returns the prime process pid for the specified job. Otherwise, a value of -1 is returned and errno is set to indicate the error.
job_getjidlist - get the currently active job jids
#include <job.h>
int job_getjidlist( jid_t *jid, int bufsize );
The job_getjidlist library call is part of the job library that allows
processes to manipulate and obtain status about linux jobs. When the job
library is to be used, the job.h header file should be included to
obtain the proper definitions.
job_getjidlist returns a list of job jid values in the array pointed
to by the jid argument. The caller is responsible for allocating and
freeing the memory for the array pointed to by jid. The return value
is the number of job jid values that were inserted into the array.
Note that bufsize is in bytes.
Upon successful completion, job_getjidlist returns a count of the number of job IDs returned in the jid array. Otherwise, a value of -1 is returned and errno is set to indicate the error.
job_create - Create a new job.
#include <job.h>
jid_t job_create( jid_t jid_requested, uid_t uid, int options );
The job_create library call is part of the job library that allows
processes to manipulate and obtain status about linux jobs. When the job
library is to be used, the job.h header file should be included to
obtain the proper definitions.
job_create will create a new job and attach the calling process to the
new job.
If the process is already part of a job, it is detached from the current job and attached to the new one.
The jid_requested parameter allows the caller to specify a jid value to use when creating the job. If the caller wants the system to generate the job ID, then set jid_requested to 0. The uid parameter is used to supply the user ID value for the user that will own the job. The options parameter is for future use.
Upon successful completion, job_create returns the job ID of the new job. Otherwise, a value of (jid_t)-1 is returned and errno is set to indicate the error.
Note: The returned value is an unsigned integer. To test for -1, you will need to use a cast. Here is an example: \
jid = job_create(0, getuid(), 0);
if (jid == (jid_t)-1) {
perror("job error");
}
job_waitjid - wait for a job to complete
#include <job.h>
jid_t job_waitjid( jid_t jid, int *status, int options );
The job_waitjid library call is part of the job library that allows
processes to manipulate and obtain status about linux jobs. When the job
library is to be used, the job.h header file should be included to
obtain the proper definitions.
job_waitjid will wait until the specified job completes, or until a
signal is delivered whose action is to terminate the current process or
to call a signal handling function. It returns the status information
for the last process to exit the job.
Upon successful completion, job_waitjid returns the job ID of the job waited for. Otherwise, a value of (jid_t)-1 is returned and errno is set to indicate the error. Note that you need to test for -1 using a cast. See the [job_create] man page for an example.
job_detachpid - detach a process from it's current job
#include <job.h>
jid_t job_detachpid( pid_t pid );
The job_detachpid library call is part of the job library that allows
processes to manipulate and obtain status about linux jobs. When the job
library is to be used, the job.h header file should be included to
obtain the proper definitions.
job_detachpid will detach a process from the job it is attached too,
but allows the processes to continue running. You need
CAP_SYS_RESOURCE capability for this to succeed.
Upon successful completion, job_detachpid returns the job ID of the job that the pid was detached from. Otherwise, a value of (jid_t)-1 is returned and errno is set to indicate the error. Note that you need to test for -1 using a cast. See the [job_create] man page for an example.
job_getpidcnt - get the number of processes attached to a job
#include <job.h>
int job_getpidcnt( jid_t jid );
The job_getpidcnt library call is part of the job library that allows
processes to manipulate and obtain status about linux jobs. When the job
library is to be used, the job.h header file should be included to
obtain the proper definitions.
job_getpidcnt returns the number of processes (pids) attached to the
specified job.
Upon successful completion, job_getpidcnt returns a count of the number of processes attached to the specified job. Otherwise, a value of -1 is returned and errno is set to indicate the error.
job_getjidcnt - return the number of jobs currently on the system
#include <job.h>
int job_getjidcnt( void );
The job_getjidcnt library call is part of the job library that allows
processes to manipulate and obtain status about linux jobs. When the job
library is to be used, the job.h header file should be included to
obtain the proper definitions.
job_getjidcnt returns the number of jobs currently running on the
system. The value will be greater than or equal to 0.
Upon successful completion, job_getjidcnt returns a count of the number of jobs currently running on the system. Otherwise, a value of -1 is returned and errno is set to indicate the error.
Linux CSA is the outcome of a joint effort between Los Alamos National Laboratory (LANL) and SGI to port the IRIX CSA tool to the Linux Operating System. This project is a community driven fork of that code base and is not supported by either organization at this time.