dupfd_register()
Register a file descriptor to be duplicated by another process
Synopsis:
#include <sys/dupfd.h>
int dupfd_register( const pid64_t dstpid,
const int fd,
const unsigned flags,
dupfd_handle_t * const handlep );
Arguments:
- dstpid
- The 32- or 64-bit process ID (PID) of the process to receive the file descriptor. Because a process's 64-bit PID cannot be reused (unlike its 32-bit PID), it is useful for uniquely identifying a process.
- fd
- The file descriptor to duplicate.
- flags
- Currently, the only valid option is DUPFD_NO_DISCARD. If specified and the limit of 200 registrations is reached, the call to dupfd_register() fails with an errno of EAGAIN.
- handlep
- Updated with the handle to use when calling dupfd().
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The dupfd_register() function registers a file descriptor to be duplicated by another process. The function generates a handle that the other process can use in a call to dupfd_register(), and writes this handle to the memory pointed to by handlep. A handle becomes invalid either after it is used or when the file descriptor it represents is closed.
If a call to dupfd_register() is made and the maximum number of registrations has been reached, the oldest unredeemed handle is replaced (unless the DUPFD_NO_DISCARD flag is set).
Returns:
0 on success, or -1 if an error occured (errno is set).
Errors:
- EBADF
- The file descriptor is not valid.
- EINVAL
- The file descriptor is invalid or is a side channel.
- ESRCH
- The process ID does not represent an existing process.
- EAGAIN
- The flag DUPFD_NO_DISCARD was specified and the limit on the number of handles has been reached.
- EFAULT
- The address specified by handlep is invalid.
Classification:
Safety: | |
---|---|
Cancellation point | No |
Signal handler | Yes |
Thread | Yes |