getrusage (BPX1GRU, BPX4GRU) — Get resource usage

Function

The getrusage callable service gets information about resources that are used by the calling process or its terminated and waited-for child processes.

Requirements

Operation Environment
Authorization: Supervisor or problem state, any PSW key
Dispatchable unit mode: Task
Cross memory mode: PASN = HASN
AMODE (BPX1GRU): 31-bit
AMODE (BPX4GRU): 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

The syntax format is as follows:

AMODE 64 callers use BPX4GRU with the same parameters.

Parameters

Who
Supplied parameter
Type:
Integer
Length:
Fullword
The name of a fullword that contains a value that indicates for whom to get the resource usage. This parameter can have one of the following values:
RUSAGE_SELF
Rusage for current process
RUSAGE_CHILDREN
Rusage for terminated children

The RUSAGE_ constants are defined in the BPXYCONS macro (see BPXYCONS — Constants used by services).

Rusage
Supplied parameter
Type:
Integer
Length:
Fullword

The name of an rusage structure that is to contain the values for resource usage. Macro BPXYRLIM defines the rusage structure (see BPXYRLIM — Map the rlimit, rusage, and timeval structures).

Return_value
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the getrusage service returns a value of zero if it is successful, and -1 if it is not successful.

Return_code
Returned parameter
Type:
Integer
Length:
Fullword
The name of a fullword in which the getrusage service stores the return code. The getrusage 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 getrusage service can return one of the following values in the Return_code parameter:
Return_code Explanation
EINVAL An incorrect Who value was specified. The following reason code can accompany the return code: JrInvalidWho.
Reason_code
Returned parameter
Type:
Integer
Length:
Fullword

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

Resource information returned for multithreaded processes may be inaccurate.

Characteristics and restrictions

There are no restrictions on the use of the getrusage service.

Examples

For an example using this callable service, see BPX1GRU (getrusage) example.