X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/2d21ac55c334faf3a56e5634905ed6987fc787d4..4bd07ac2140668789aa3ee8ec4dde4a3e0a3bba5:/bsd/man/man2/dup.2 diff --git a/bsd/man/man2/dup.2 b/bsd/man/man2/dup.2 index 019b13fbf..897966a52 100644 --- a/bsd/man/man2/dup.2 +++ b/bsd/man/man2/dup.2 @@ -33,7 +33,7 @@ .\" .\" @(#)dup.2 8.1 (Berkeley) 6/4/93 .\" -.Dd June 4, 1993 +.Dd December 1, 2010 .Dt DUP 2 .Os BSD 4 .Sh NAME @@ -100,12 +100,22 @@ In the value of the new descriptor .Fa fildes2 is specified. -If this descriptor is already in use, -the descriptor is first deallocated as if a +If +.Fa fildes +and +.Fa fildes2 +are equal, then +.Fn dup2 +just returns +.Fa fildes2 ; +no other changes are made to the existing descriptor. +Otherwise, if descriptor +.Fa fildes2 +is already in use, it is first deallocated as if a .Xr close 2 call had been done first. .Sh RETURN VALUES -Upon successful completion, a value of 0 is returned. +Upon successful completion, the new file descriptor is returned. Otherwise, a value of -1 is returned and the global integer variable .Va errno is set to indicate the error. @@ -119,8 +129,6 @@ system calls will fail if: .\" ========== .It Bq Er EBADF .Fa fildes -or -.Fa fildes2 is not an active, valid file descriptor. .\" ========== .It Bq Er EINTR @@ -129,6 +137,16 @@ Execution is interrupted by a signal. .It Bq Er EMFILE Too many file descriptors are active. .El +.Pp +The +.Fn dup2 +system call will fail if: +.Bl -tag -width Er +.\" ========== +.It Bq Er EBADF +.Fa fildes2 +is negative or greater than the maximum allowable number (see getdtablesize(2)). +.El .Sh SEE ALSO .Xr accept 2 , .Xr close 2 ,