NAME | SYNOPSIS | API RESTRICTIONS | FEATURES | DESCRIPTION | RETURN VALUE | ERRORS | ATTRIBUTES | SEE ALSO
#include <unistd.h>int dup(int fildes);
The function or functions documented here may not be used safely in all application contexts with all APIs provided in the ChorusOS 5.0 product.
See API(5FEA) for details.
MSDOSFS, NFS_CLIENT, UFS, POSIX_SOCKETS, POSIX_SHM
The fildes file contains a file descriptor obtained from an open (2POSIX), dup , accept (2POSIX), socket (2POSIX), or shm_open (2POSIX) system call. The dup function returns a new file descriptor which has the following in common with the original:
Same open file (socket or shared memory object)
Same file pointer (both file descriptors share one file pointer)
Same access mode (read, write or read/write).
The new file descriptor is set to remain open across posix_spawn (2POSIX) system calls. See fcntl (2POSIX).
The file descriptor returned is the lowest one available.
The dup2 system call performs a similar function. In this form of the call, fildes is a non-negative integer less than OPEN_MAX as returned by aconf(2K) or sysconf(3POSIX) . The dup2 call causes fildes2 to refer to the same file as fildes . If fildes2 already refers to an open file, it is closed first.
Upon successful completion a non-negative integer, namely the file descriptor, is returned. Otherwise, a value of -1 is returned and errno is set to indicate one of the following error conditions.
fildes is not a valid open file descriptor.
OPEN_MAX file descriptors are currently open.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
MT-Level | Async-Signal-Safe |
accept(2POSIX) , posix_spawn(2POSIX) , close(2POSIX) , fcntl(2POSIX) , open(2POSIX) , socket(2POSIX) , shm_open(2POSIX) , aconf(2K) , sysconf(3POSIX)
NAME | SYNOPSIS | API RESTRICTIONS | FEATURES | DESCRIPTION | RETURN VALUE | ERRORS | ATTRIBUTES | SEE ALSO