__pid_affinity (BPX1PAF, BPX4PAF) — Add or delete an entry in a process's affinity list

Function

The __pid_affinity service 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 event. The __pid_affinity service dynamically creates or breaks an association between two processes. Its function is similar to the notification mechanism between parent and child processes, except that in this case the processes are not related in any way.

Requirements

Operation Environment
Authorization: Supervisor state or problem state, any PSW key
Dispatchable unit mode: Task
Cross memory mode: PASN = HASN
AMODE (BPX1PAF): 31-bit
AMODE (BPX4PAF): 64-bit
ASC mode: Primary mode
Interrupt status: Enabled for interrupts
Locks: Unlocked
Control parameters: All parameters must be addressable by the caller and in the primary address space.

Format

CALL BPX1PAF,(Function_code,
              Target_Pid,
              Signal_Pid,
              Signal,
              Return_value,
              Return_code,
              Reason_code)

AMODE 64 callers use BPX4PAF with the same parameters.

Parameters

Function_code
Supplied parameter
Type:
Integer
Length:
Fullword

The name of a fullword that specifies a numeric value that identifies the function to be performed. The following Function_code constants are defined by the BPXYCONS macro (see BPXYCONS — Constants used by services):

Constant Function
PAF_ADD_PID# The process and associated signal that are specified by Signal_Pid are to be added to the affinity list of the process that is specified by Target_Pid.
PAF_DELETE_PID# The process and associated signal that are specified by Signal_Pid are to be deleted from the affinity list of the process that is specified by Target_Pid.
Target_Pid
Supplied parameter
Type:
Integer
Length:
Fullword

The name of a fullword that specifies a numeric value that identifies the PID (Process ID) of the process whose affinity list is to be altered. See the usage notes for limitations on the PIDs that can be specified.

Signal_Pid
Supplied parameter
Type:
Integer
Length:
Fullword

The name of a fullword that specifies a numeric value that identifies the PID (Process ID) of the process that, when the Target_Pid process terminates, is to be sent the signal that is specified by the Signal parameter. See the usage notes for limitations on the PIDs that can be specified.

Signal
Supplied parameter
Type:
Integer
Length:
Fullword

The name of a fullword that specifies a numeric value that identifies the signal that the Signal_Pid process is to receive when the process that is specified by Target_Pid terminates. The signal must be one that is defined by the BPXYSIGH macro.

Return_value
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the __pid_affinity service returns 0 if the request is successful, or -1 if it is not successful.

Return_code
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the __pid_affinity service stores the return code. The __pid_affinity service returns Return_code only if Return_value is -1. For a complete list of possible return code values, see z/OS UNIX System Services Messages and Codes. The __pid_affinity service can return one of the following values in the Return_code parameter:

Return_code Explanation
EINVAL One or more of the following conditions were detected:
  • The value of 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.
  • Signal_Pid and Target_Pid are the same.

The following reason codes can accompany the return code: JRInvalidSignal, JRTargetPid, JRPidsSame, and JRSignalPid.

EPERM The caller does not have permission to send a signal to the process that is specified on the Signal_Pid parameter.
EMVSSAF2ERR A System Authorization Facility (SAF) or RACF® call had an error.
ESRCH One or more of the following conditions were detected:
  • No process was found that corresponds to Target_Pid.
  • No process was found that corresponds to Signal_Pid.

The following reason codes can accompany the return code: JRTargetPid and JRSignalPid.

Reason_code
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the __pid_affinity service stores the reason code. The __pid_affinity service returns Reason_code only if Return_value is -1. Reason_code further qualifies the Return_code value. For the reason codes, see z/OS UNIX System Services Messages and Codes.

In the case of EMVSSAF2ERR, Reason_code contains the RACF return and reason codes, respectively, in the two low-order bytes. For a more detailed description of the RACF Check Privilege service return and reason code values, see the following table:

RACF return code RACF reason code Explanation
8 4 The caller is not the owner of the target process.
8 12 There was an internal error during RACF processing.

Usage notes

  1. The PIDs that are specified by the Target_Pid and Signal_Pid parameters must be greater than 1. Specifying a PID that is equal to or less than 1 results in an error.
  2. In order for the caller to add an entry to the affinity list of a process (Target_Pid), the Signal_Pid process must exist, and the caller's process must have permission to send it a signal.
  3. During process termination, the process attempts to send all the specified signals to the corresponding PID or PIDs in its affinity list. If a signal cannot be sent (for instance, if the process has already terminated), termination continues.
  4. If a process changes identity after it has been added to another process's affinity list, the signal is sent upon process termination without permission being reverified.
  5. Identical entries that contain the same PID (Signal_Pid) and signal are not allowed in a process's affinity list. If an attempt is made to add a process and an identical entry is found, the service completes successfully without adding another entry.
  6. To delete an entry from an affinity list, the PID (Signal_Pid) specified by the caller must be the same as an entry in the Target_Pid process's affinity list.

Related services

Characteristics and restrictions

None.

Examples

For an example using this callable service, see BPX1PAF (__pid_affinity) example.