From ac225cf76dfd6293ef024bdd2a3a7a24787bacb3 Mon Sep 17 00:00:00 2001 From: Stephen McKay Date: Sun, 9 Mar 1997 13:16:48 +0000 Subject: Clarified the behaviour of dup2(fd1,fd2) when fd1==fd2 and when fd1 is invalid. Safe for 2.2! --- lib/libc/sys/dup.2 | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/libc/sys/dup.2 b/lib/libc/sys/dup.2 index 66c9d29728c54..58a967d22e015 100644 --- a/lib/libc/sys/dup.2 +++ b/lib/libc/sys/dup.2 @@ -30,7 +30,7 @@ .\" SUCH DAMAGE. .\" .\" @(#)dup.2 8.1 (Berkeley) 6/4/93 -.\" $Id$ +.\" $Id: dup.2,v 1.7 1997/02/22 15:03:49 peter Exp $ .\" .Dd June 4, 1993 .Dt DUP 2 @@ -92,10 +92,27 @@ In .Fn dup2 , the value of the new descriptor .Fa newd -is specified. If this descriptor is already -in use, the descriptor is first deallocated as if a +is specified. If this descriptor is already in use and +.Fa oldd +!= +.Fa newd , +the descriptor is first deallocated as if a .Xr close 2 -call had been done first. +call had been used. +If +.Fa oldd +is not a valid descriptor, then +.Fa newd +is not closed. +If +.Fa oldd +== +.Fa newd +and +.Fa oldd +is a valid descriptor, then +.Fn dup2 +is successful, and does nothing. .Sh IMPLEMENTATION NOTES .Pp In the non-threaded library -- cgit v1.3