Next: , Previous: , Up: posix fd   [Index]


4.13.9 Duplicating file descriptors

The functions dup and dup2 are often used to prepare the standard file descriptors of a child process right after a fork call; Creating a subprocess, for details about this usage.

Function: dup fd

Interface to the C function dup(), (libc)dup. Duplicate the file descriptor fd. If successful return a non–negative fixnum representing the new descriptor, else raise an exception.

Function: dup2 old new

Interface to the C function dup2(), (libc)dup. Duplicate the file descriptor old to new. If successful return unspecified values, else raise an exception.