Standards
Standards / Extensions |
C or C++ |
Dependencies |
z/OS® UNIX |
both |
OS/390 V2R6 |
Format
#define _OPEN_SYS
#include <unistd.h>
int __pid_affinity(int function_code,
pid_t target_pid,
pid_t signal_pid,
int signal);
General description
The __pid_affinity() function adds or deletes an entry in a process's
affinity list. When a process terminates, each process in its affinity
list is notified (sent a signal) of the termination. The __pid_affinity()
function provides the ability to dynamically create or break an association
between two processes that is similar to the notification mechanism
between parent and child processes without the processes being related.
The
function_code can be set to one of the following symbolics,
as defined in the unistd.h header file:
- __PAF_ADD_PID
- Add the process and signal specified by signal_pid and signal to
the affinity list of the process specified by target_pid.
- __PAF_DELETE_PID
- Delete the process and signal specified by signal_pid and signal from
the affinity list of the process specified by target_pid.
The target_pid identifies the process whose affinity list
will be altered.
The signal_pid identifies the process that upon termination
of the target_pid will be sent signal signal.
The signal identifies the signal that the signal_pid process
will receive when the target_pid process terminates.
Usage notes
- Either the Target_Pid or Signal_Pid must contain
the PID of the caller's process.
- The __pid affinity service is limited to adding and deleting entries
in the caller's affinity list, or adding and deleting entries that
contain the caller's PID (Signal_Pid) in other processes
affinity list.
- When the PAF_DELETE_PID# function is specified the Signal is
ignored. It is not validated and may contain any value.
- An entry is only deleted (PAF_DELETE_PID# specified) when the Signal_Pid matches
an entry in the Target_Pid process's affinity list.
- Entries with duplicate PIDs are not allowed in an affinity list.
If adding an entry (PAF_ADD_PID# specified) and an entry with a PID
that matches the Signal_Pid is found the entry is reused.
This may result in the loss of a specific signal.
- No permission is required when adding the caller's PID to another
process's affinity list. All processes have permission to send a signal
to themselves (raise()).
- The PIDs specified by the Target_Pid and Signal_Pid parameters
must be greater than 1. Specifying a PID equal to or less than 1 will
result in a error.
Returned value
If successful, __pid_affinity() returns 0.
If unsuccessful, __pid_affinity() returns -1 and sets errno
to one of the following values:
- Error Code
- Description
- EINVAL
- One or more of the following conditions were detected:
- The value specified by Function_code is not supported.
- The value specified by Signal is not a supported signal.
- Target_Pid does not contain a value greater than 1.
- Signal_Pid does not contain a value greater than 1.
- The Signal_Pid or Target_Pid does not specify
the caller PID.
- EMVSERR
- A MVS™ environmental or
internal error has occurred.
- EMVSSAF2ERR
- An internal SAF/RACF error has occurred.
- EPERM
- The caller does not have permission to send the signal to the Signal_Pid process.
- ESRCH
- One or more of the following conditions were detected:
- No process corresponding to Target_Pid was found.
- No process corresponding to Signal_Pid was found.