#include <unistd.h> #include <fcntl.h> int fcntl(int fd, int cmd); int fcntl(int fd, int cmd, long arg);
The same functionality can be more easily achieved by using dup2.
The old and new descriptors may be used interchangeably. They share locks, file position pointers and flags; for example, if the file position is modified by using lseek on one of the descriptors, the position is also changed for the other.
The two descriptors do not share the close-on-exec flag, however.
On success, the new descriptor is returned.
The flags are shared between copies (made with dup etc.) of the same file descriptor. The flags are shared between copies (made with dup etc.) of the same file descriptor.
The flags and their semantics are described in open(2).
Process groups are returned as negative values.
For these commands, ownership means receiving SIGIO or SIGURG signals.
Process groups are specified using negative values.
On error, -1 is returned, and errno is set appropriately.