The synopsis is at the bottom of page and I am only concern with OS2 __386__.
int _pipe( int *phandles, unsigned psize, int textmode );
If psize == 0 then default size of 4096 will be used.
HFILE hRead
HFILE hWrite;
APIRET rc;
rc = DosCreatePipe( &hRead, &hWrite, psize );
Handle is inheritable by default
Initialize the POSIX-level handles
hWritePosix = _hdopen( (int)hWrite, textmode|_O_WRONLY );
The _hdopen function takes a previously opened operating system file handle specified by os_handle and opened with access and sharing specified by mode, and creates a POSIX-style file handle.
Store the new POSIX handles in return buffer
phandles[1] = hWritePosix;
Synopsis:
#include
int _pipe( int *phandles, unsigned psize, int textmode );
Description:
The _pipe function creates a pipe (an unnamed FIFO) and places a file descriptor for the read end of the pipe in phandles[0] and a file descriptor for the write end of the pipe in phandles[1]. Their integer values are the two lowest available at the time of the _pipe function call. The O_NONBLOCK flag is cleared for both file descriptors. (The fcntl call can be used to set the O_NONBLOCK flag.)
Data can be written to file descriptor phandles[1] and read from file descriptor phandles[0]. A read on file descriptor phandles[0] returns the data written to phandles[1] on a first-in-first-out (FIFO) basis.
This function is typically used to connect together standard utilities to act as filters, passing the write end of the pipe to the data producing process as its STDOUT_FILENO and the read end of the pipe to the data consuming process as its STDIN_FILENO. (either via the traditional fork/dup2/exec or the more efficient spawn calls).
If successful, _pipe marks for update the st_ftime, st_ctime, st_atime and st_mtime fields of the pipe for updating.
Returns:
The _pipe function returns zero on success. Otherwise, (-1) is returned and errno is set to indicate the error.
Errors:
When an error has occurred, errno contains a value indicating the type of error that has been detected. If any of the following conditions occur, the _pipe function shall return (-1) and set errno to the corresponding value:
Constant Meaning
EMFILE The calling process does not have at least 2 unused file descriptors available.
ENFILE The number of simultaneously open files in the system would exceed the configured limit.
ENOSPC There is insufficient space available to allocate the pipe buffer.
EROFS The pipe pathname space is a read-only filesystem.