Skip to content

Job C Functions

jgrantham-SGI edited this page Jun 9, 2016 · 1 revision

job_sethid


 

NAME

job_sethid - set hid for new job IDs  

SYNOPSIS

#include <job.h>

int job_sethid( unsigned int hid );

 

DESCRIPTION

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.

 

DIAGNOSTICS

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


 

NAME

job\_detachjid - detach all the processes from a job  

SYNOPSIS

#include <job.h>

int job_detachjid( jid_t jid );

 

DESCRIPTION

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.

 

DIAGNOSTICS

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


 

NAME

job\_getuid - get the user ID of a job  

SYNOPSIS

#include <job.h>

uid_t job_getuid( jid_t jid );

 

DESCRIPTION

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.

 

DIAGNOSTICS

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


 

NAME

job\_getjid - return the job ID for the given process  

SYNOPSIS

#include <job.h>

jid_t job_getjid( pid_t pid );

 

DESCRIPTION

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.  

DIAGNOSTICS

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


 

NAME

job_attachpid - attach a process to a requested job  

SYNOPSIS

#include <job.h>

jid_t job_attachpid( pid_t pid, jid_t jid_requested );

 

DESCRIPTION

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.

 

DIAGNOSTICS

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


 

NAME

job_killjid - send a signal to all processes in a job  

SYNOPSIS

#include <job.h>

int job_killjid( jid_t jid, int sig );

 

DESCRIPTION

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.

 

DIAGNOSTICS

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


 

NAME

job_getpidlist - get the list of process pids attached to a job  

SYNOPSIS

#include <job.h>

int job_getpidlist( jid_t jid, pid_t *pid, int bufsize );

 

DESCRIPTION

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.

 

DIAGNOSTICS

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


 

NAME

job_getprimepid - get the prime process pid for a job  

SYNOPSIS

#include <job.h>

pid_t job_getprimepid( jid_t jid );

 

DESCRIPTION

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.

 

DIAGNOSTICS

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


 

NAME

job_getjidlist - get the currently active job jids  

SYNOPSIS

#include <job.h>

int job_getjidlist( jid_t *jid, int bufsize );

 

DESCRIPTION

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.

 

DIAGNOSTICS

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


 

NAME

job_create - Create a new job.  

SYNOPSIS

#include <job.h>

jid_t job_create( jid_t jid_requested, uid_t uid, int options );

 

DESCRIPTION

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.

 

DIAGNOSTICS

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


 

NAME

job_waitjid - wait for a job to complete  

SYNOPSIS

#include <job.h>

jid_t job_waitjid( jid_t jid, int *status, int options );

 

DESCRIPTION

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.

 

DIAGNOSTICS

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


 

NAME

job_detachpid - detach a process from it's current job  

SYNOPSIS

#include <job.h>

jid_t job_detachpid( pid_t pid );

 

DESCRIPTION

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.

 

DIAGNOSTICS

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


 

NAME

job_getpidcnt - get the number of processes attached to a job  

SYNOPSIS

#include <job.h>

int job_getpidcnt( jid_t jid );

 

DESCRIPTION

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.

 

DIAGNOSTICS

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


 

NAME

job_getjidcnt - return the number of jobs currently on the system  

SYNOPSIS

#include <job.h>

int job_getjidcnt( void );

 

DESCRIPTION

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.

 

DIAGNOSTICS

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.