dup3 man page on SmartOS

Man page or keyword search:  
man Server   16655 pages
apropos Keyword Search (all sections)
Output format
SmartOS logo
[printable version]

DUP2(3C)							      DUP2(3C)

       dup2, dup3 - duplicate an open file descriptor

       #include <unistd.h>

       int dup2(int fildes, int fildes2);

       int dup3(int fildes, int fildes2, Bint flags);

       The  dup2() function causes the file descriptor fildes2 to refer to the
       same file as fildes. The fildes argument is a file descriptor referring
       to  an  open  file, and fildes2 is a non-negative integer less than the
       current value for the maximum number of open file descriptors   allowed
       the calling process.  See getrlimit(2). If fildes2 already refers to an
       open file, not fildes, it is closed first. If fildes2 refers to fildes,
       or  if  fildes is not a valid open file descriptor, fildes2 will not be
       closed first.

       The dup2() function is equivalent to  fcntl(fildes, F_DUP2FD, fildes2).

       Ths dup3() function works similarly to the  dup2()  function  with  two
       exceptions.   If	 fildes and fildes2 point to the same file descriptor,
       -1 is returned and errno set to EINVAL.	If flags  is  O_CLOEXEC,  then
       filedes2	 will have the FD_CLOEXEC flag set causing the file descriptor
       to be closed during any future call of exec(2).

       Upon successful completion a non-negative integer representing the file
       descriptor  is  returned. Otherwise, −1 is returned and errno is set to
       indicate the error.

       The dup2() and dup3() functions will fail if:

		 The fildes argument is not a valid open file descriptor.

		 The fildes2 argument is negative or is not less than the cur‐
		 rent  resource	 limit	returned  by  getrlimit(RLIMIT_NOFILE,

		 A signal was caught during the dup2() call.

		 The process has too many open files.  See  fcntl(2).

       Additionally, the dup3() function will fail if:

		 flags has a value other than 0 or  O_CLOEXEC  or  fildes  and
		 fildes2 point to the same file descriptor.

       See attributes(5) for descriptions of the following attributes:

       │Interface Stability │ Standard		│
       │MT-Level	    │ Async-Signal-Safe │

       close(2),  creat(2), exec(2), fcntl(2), getrlimit(2), open(2), pipe(2),
       attributes(5), standards(5)

				 Apr 19, 2013			      DUP2(3C)

List of man pages available for SmartOS

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
Vote for polarhome
Free Shell Accounts :: the biggest list on the net