Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
spt_dup2x(2) OSS System Calls Reference Manual
NOTES
The macro to map dup2( ) to spt_dup2x( ) is available in C applications when
SPT_THREAD_AWARE_NONBLOCK has been defined in the following manner before
including spthread.h:
#define SPT_THREAD_AWARE_NONBLOCK
The alias to link dup2( ) to spt_dup2x( ) is available in C++ applications when
SPT_THREAD_AWARE_PRAGMA_NONBLOCK has been defined in the following manner
before including spthread.h:
#define SPT_THREAD_AWARE_PRAGMA_NONBLOCK
To use this function in a threaded application that uses the Standard POSIX Threads library on
systems running J06.10 or later RVUs or H06.21 or later RVUs, you must perform all of the fol-
lowing tasks:
• Include the spthread.h header file in the application.
• Compile the application using the _SPT_MODEL_ feature test macro or equivalent
compiler command option in addition to any other feature test macros in use.
• Link the application to the zsptdll library (/G/system/zdllnnn/zsptdll).
The spt_dup2x( ) function provides an alternative interface to the service provided by the
spt_fcntlx() function by using the F_DUPFD value of the request parameter. The call:
fid = spt_dup2x( file1, file2 );
is equivalent to:
close( file2 );
fid = spt_fcntlx( file1, F_DUPFD, file2 );
RETURN VALUES
Upon successful completion, the spt_dup2x() function returns a new file descriptor. Otherwise,
the value -1 is returned, and errno is set to indicate the error.
ERRORS
If any of these conditions occur, the spt_dup2x( ) function sets errno to the corresponding value:
[EBADF] One of these conditions exists:
• The filedes parameter is not a valid open file descriptor.
• The new parameter file descriptor is negative or greater than the max-
imum number of open file descriptors permitted.
[EISGUARDIAN]
The value used for the filedes parameter is appropriate only in the Guardian
environment.
[EWRONGID] One of these conditions occurred:
• The process attempted an operation on an input/output process (such as a
terminal server process) that has failed or is in the down state.
7−154 Hewlett-Packard Company 527186-023