setpgid (BPX1SPG, BPX4SPG) — Set a process group ID for job control

Function

The setpgid callable service places a process in a process group. You identify the group by specifying a process group ID. You can assign a process to a different group, or you can start a new group with that process as its leader.

Requirements

Operation Environment
Authorization: Supervisor state or problem state, any PSW key
Dispatchable unit mode: Task
Cross memory mode: PASN = HASN
AMODE (BPX1SPG): 31-bit
AMODE (BPX4SPG): 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 BPX1SPG,(Process_ID,
              Process_group_ID,
              Return_value,
              Return_code,
              Reason_code)

AMODE 64 callers use BPX4SPG with the same parameters.

Parameters

Process_ID
Supplied parameter
Type:
Integer
Length:
Fullword

The name of a fullword that contains the ID of the process that is to be placed in the process group. If the ID is specified as 0, the system uses the process ID of the calling process.

Process_group_ID
Supplied parameter
Type:
Integer
Length:
Fullword

The name of a fullword that contains the ID of the process group where Process_ID is assigned. If the ID is specified as 0, the system uses the process group ID that is indicated by the Process_ID parameter.

Return_value
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the setpgid 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 setpgid service stores the return code. The setpgid service returns Return_code only if Return_value is -1. See z/OS UNIX System Services Messages and Codes for a complete list of possible return code values. The setpgid service can return one of the following values in the Return_code parameter:
Return_code Explanation
EACCES The value of Process_ID matches the process ID of a child of the calling process, but the child has successfully invoked one of the exec functions. Access to the target process was denied. The following reason code can accompany the return code: JRExecAfterFork.
EINVAL The Process_group_ID parameter is less than zero or has some other unsupported value. The following reason codes can accompany the return code: JRNoSuchPid and JRPgidDifferentSession.
EPERM The calling process cannot change the process group ID of the specified process. The following reason codes can accompany the return code: JRPidEQSessLeader, JRPidDifferentSession, and JRPgidDifferentSession.
ESRCH The specified Process_ID is not that of the calling process or any of its children. The following reason codes can accompany the return code: JRNotDescendant and JRNoSuchPid.
Reason_code
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the setpgid service stores the reason code. The setpgid 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.

Usage notes

  1. The process group ID that is to be assigned to the group must be within the calling process's session.
  2. The subject process (the process identified by the Process_ID parameter) must be a child of the process that issues the service and must be in the same session, but it cannot be the session leader. It can be the caller.

Related services

Characteristics and restrictions

See the conditions described under Return_code.

Examples

For an example using this callable service, see BPX1SPG (setpgid) example.