Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
System Functions (s and S) spt_dup2x(2)
NAME
spt_dup2x - Duplicates and controls an open file descriptor (thread-aware version)
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series and J series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
[#include <unistd.h>]
#include <spthread.h>
int spt_dup2x(
int filedes,
int new);
PARAMETERS
filedes Specifies an open file descriptor obtained from a successful call to the
spt_acceptx(), creat(), dup(), spt_dup2x(), spt_fcntlx(), open(), pipe(),
socket(),orsocketpair() function.
new Specifies the open file descriptor that is returned by the spt_dup2x() function. If
this descriptor is already in use, it is first deallocated as if it had been closed.
DESCRIPTION
The spt_dup2x( ) function is a thread-aware version of the dup2() function.
The spt_dup2x( ) function returns a new file descriptor on the open file specified by the filedes
parameter. If new is less than 0 (zero) or greater than or equal to the maximum number of opens
permitted, spt_dup2x( ) returns -1 with errno set to [EBADF].
The new file descriptor:
• Is the value specified as the new parameter:
—Iffiledes is a valid file descriptor and is equal to new, spt_dup2x() returns new
without closing it.
—Iffiledes is not a valid file descriptor, spt_dup2x() returns -1 and does not close
new.
— The value returned is equal to the value of new upon successful completion, or it
is -1 upon failure.
• References the same open file descriptor
• Returns the same file pointer as the original file (that is, both file descriptors share one
file pointer if the object is a file)
• Returns the same access mode (read, write, or read/write)
• Returns the same file status flags (that is, both file descriptors share the same file status
flags)
• Clears the close-on-exec flag (FD_CLOEXEC bit) associated with the new file descrip-
tor so that the file remains open across calls to any function in the exec, tdm_exec, and
tdm_spawn sets of functions
527186-023 Hewlett-Packard Company 7−153