Qp0wChkPid()--Check Status for Process ID


  Syntax
 #include <sys/types.h>
 #include <qp0wpid.h>

 int Qp0wChkPid(pid_t pid,
                QP0W_PID_Data_T *pidinfo);  

  Service Program Name: QP0WPID

  Default Public Authority: *USE

  Threadsafe: Yes

The Qp0wChkPid() function returns the status and process table entry information for the process specified by the process ID pid.


Parameters

pid
(Input) The process ID of the process whose process table information is to be returned. When pid has a value of binary 0, the process table information for the current process is returned.

*pidinfo
(Output) A pointer to the QP0W_PID_Data_T structure. The process table entry information for the process identified by pid is stored in the location pointed to by the pidinfo parameter.

The structure QP0W_PID_Data_T is defined in <qp0wpid.h> header file as follows:

typedef struct QP0W_PID_Data_T {
    pid_t         pid;
    pid_t         ppid;
    pid_t         pgrp;
    int           status;
    unsigned int  exit_status;
} QP0W_PID_Data_T;

The members of the QP0W_PID_Data_T structure are as follows:

pid_t pid; The process ID of the process.
pid_t ppid; The process ID of the parent process. If ppid has a value of binary 1, there is no parent process associated with the process.
pid_t pgrp; The process group ID of the process.
int status; A collection of flag bits that describe the current state of the process. The following flag bits can be set in status:
QP0W_PID_TERMINATED The process has ended.
QP0W_PID_StopPED The process has been stopped by a signal.
QP0W_PID_CHILDWAIT The process is waiting for a child process to be ended or stopped by a signal.
QP0W_PID_SIGNALStop The process has requested that the SIGCHLD signal be generated for the process when one of it's child processes has been stopped by a signal.

unsigned int exit_status; Exit status of the process. This member only has meaning if the status has been set to QP0W_PID_TERMINATED. Refer to the wait() function for a description of the exit status for a process.


Authorities

The process calling Qp0wChkPid() must have the appropriate authority to the process being examined. A process is allowed to examine the process table information for a process if at least one of the following conditions is true:


Return Value

0 Qp0wChkPid() was successful.
value Qp0wChkPid() was not successful. The value returned indicates one of the following errors. Under some conditions, value could indicate an error other than those listed here.
[EINVAL] The value specified for the argument is not correct.

A function was passed incorrect argument values, or an operation was attempted on an object and the operation specified is not supported for that type of object.

An argument value is not valid, out of range, or NULL.

[EPERM] Operation not permitted.

You must have appropriate privileges or be the owner of the object or other resource to do the requested operation.

[ESRCH] No item could be found that matches the specified value.


Usage Notes

The Qp0wChkPid() function provides an i5/OS-specific way to obtain the process table information for the specified process.

Related Information



API introduced: V3R6
Top | UNIX-Type APIs | APIs by category