dup2() vs dup3() inconsistency when

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Michael Kerrisk
Date: Thursday, October 9, 2008 - 5:10 am

Al,

your 2008-07-26 commit 6c5d0512a091480c9f981162227fdb1c9d70e555 for
fs/fcntl.c:sys_dup3 contains

+       if (unlikely(oldfd == newfd))
+               return -EINVAL;

This makes dup2() and dup3() differ with respect to the oldfd==newfd
case (dup2() becomes a no-op, just returning oldfd, dup3() gives the
EINVAL error.

Your commit log doesn't explain the rationale for this change.  What
is it?  (I could guess that it is to error on a case that may be a
user programming error, but I want to check this with you, so that I
add the right text to the man page.)

Cheers,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
git://git.kernel.org/pub/scm/docs/man-pages/man-pages.git
man-pages online: http://www.kernel.org/doc/man-pages/online_pages.html
Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
dup2() vs dup3() inconsistency when, Michael Kerrisk, (Thu Oct 9, 5:10 am)
Re: dup2() vs dup3() inconsistency when, H. Peter Anvin, (Thu Oct 9, 10:21 am)
Re: dup2() vs dup3() inconsistency when, Ulrich Drepper, (Thu Oct 9, 1:31 pm)
Re: dup2() vs dup3() inconsistency when, H. Peter Anvin, (Thu Oct 9, 1:43 pm)
Re: dup2() vs dup3() inconsistency when, Ulrich Drepper, (Thu Oct 9, 1:52 pm)
Re: dup2() vs dup3() inconsistency when, H. Peter Anvin, (Thu Oct 9, 1:57 pm)
Re: dup2() vs dup3() inconsistency when, Ulrich Drepper, (Thu Oct 9, 2:04 pm)
Re: dup2() vs dup3() inconsistency when, Michael Kerrisk, (Thu Oct 9, 10:01 pm)
Re: dup2() vs dup3() inconsistency when, Michael Kerrisk, (Thu Oct 9, 10:04 pm)
Re: dup2() vs dup3() inconsistency when, Bernd Petrovitsch, (Fri Oct 10, 5:09 am)
Re: dup2() vs dup3() inconsistency when, Michael Kerrisk, (Fri Oct 10, 5:15 am)
Re: dup2() vs dup3() inconsistency when, Bernd Petrovitsch, (Fri Oct 10, 6:02 am)
Re: dup2() vs dup3() inconsistency when, Michael Kerrisk, (Fri Oct 10, 6:15 am)
Re: dup2() vs dup3() inconsistency when, Bernd Petrovitsch, (Fri Oct 10, 6:31 am)
Re: dup2() vs dup3() inconsistency when, Heikki Orsila, (Fri Oct 10, 6:43 am)