Re: [RFC] Subtle race in dup2() and permissions on /proc/<pid>/fd/<n>

Guest section DW (dwguest@win.tue.nl)
Fri, 25 Jun 1999 02:59:48 +0200 (MET DST)


viro asks:

> dup2(foo, bar) closes bar, but completely ignores the results of
> close(). POSIX position on that?

The call
fd = dup2(fd1,fd2);
is equivalent to
close(fd2);
fd = fcntl(fd1, F_DUPFD, fd2);
except that
- if fd1==fd2 and both are valid, then dup2() returns this
without closing fd2
- if fd1 is invalid, dup2 returns -1 without closing fd2

So, yes, it looks like there is no provision for returning
close() errors here.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/