pipe (BPX1PIP, BPX4PIP) — Create an unnamed pipe

Function

The pipe callable service creates a pipe. A pipe is an I/O channel that a process can use to communicate with another process, with another thread (in this same process or another process), or in some cases with itself. Data can be written into one end of the pipe and read from the other.

Requirements

Operation Environment
Authorization: Supervisor state or problem state, any PSW key
Dispatchable unit mode: Task
Cross memory mode: PASN = HASN
AMODE (BPX1PIP): 31-bit
AMODE (BPX4PIP): 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 BPX4PIP with the same parameters.

Parameters

Read_file_descriptor
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the pipe service stores the file descriptor for the read end of the pipe if the pipe is created successfully.

Write_file_descriptor
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the pipe service stores the file descriptor for the write end of the pipe if the pipe is created successfully.

Return_value
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the pipe 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 pipe service stores the return code. The pipe 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 pipe service can return one of the following values in the Return_code parameter:
Return_code Explanation
EMFILE The process has either reached the maximum number of file descriptors it can have open, or the current pipe limit was exceeded. Refer to the reason code that was provided.
ENFILE Opening the pipe would exceed the number of files that the system can have open simultaneously.
Reason_code
Returned parameter
Type:
Integer
Length:
Fullword

The name of a fullword in which the pipe service stores the reason code. The pipe 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. Processes can read from the Read_file_descriptor and write to the Write_file_descriptor. Data written will be read first-in, first-out (FIFO).
  2. When the pipe call creates a pipe, the O_NONBLOCK and FD_CLOEXEC flags are turned off on both ends of the pipe. You can turn on these flags with the fcntl call; see fcntl (BPX1FCT, BPX4FCT) — Control open file descriptors.

Characteristics and restrictions

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

Examples

For an example using this callable service, see BPX1PIP (pipe) example.