Re: dup2() vs dup3() inconsistency when

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: H. Peter Anvin
Date: Thursday, October 9, 2008 - 1:43 pm

Ulrich Drepper wrote:

The result of dup3(fd, fd, O_CLOEXEC) is to set the O_CLOEXEC flag on fd.

The behaviour of dup2() is functionally the following:

1. Duplicate the file descriptor from file_table[oldfd].
2. If file_table[newfd] is in use, close it.
3. Install the duplicate file descriptor at file_table[newfd].

Step (2) could be considered a bit dubious, but the behaviour of 
dup2(fd, fd) is a direct consequence of the chosen semantics.

	-hpa
--
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)