z/OS Using REXX and z/OS UNIX System Services
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


dup2

z/OS Using REXX and z/OS UNIX System Services
SA23-2283-00

Read syntax diagramSkip visual syntax diagram
>>-dup2--fd--fd2-----------------------------------------------><

Function

dup2 invokes the fcntl callable service to duplicate an open file descriptor to the file descriptor of choice. The file descriptor returned is equal to fd2. If fd2 is already in use, it is closed and fd is duplicated. If fd is equal to fd2, fd2 is returned without closing it. The file descriptor is returned in RETVAL.

Parameters

fd
An opened file descriptor (a number) to be duplicated.
fd2
The file descriptor (a number) to be changed.

Usage notes

dup fd fd2 is equivalent to F_DUPFD fd fd2.

Example

In the following example, assume that fd1 and fd2 were assigned values earlier in the exec:
"dup2" fd1 fd2

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014