Jilles Tjoelker
2014-05-08 20:41:11 UTC
Hi,
I found some issues in bug411_atomic_CLOEXEC.pdf.
On page 2, there is
accept4(sock, addr, len, O_NONBLOCK)
which should at least be (but see below)
accept4(sock, addr, len, SOCK_NONBLOCK)
(Note that this mistake will not be detected on Linux/glibc because the
values are equal; however, on FreeBSD, the value of O_NONBLOCK is 4 and
the value of SOCK_SEQPACKET is 5, so SOCK_NONBLOCK cannot be equal to
O_NONBLOCK.)
Although O_NONBLOCK is the most common property where the difference is
apparent, BSD copies a few more properties to the new socket: the
O_ASYNC property and the signal destination as set by fcntl(F_SETOWN).
The latter property is also part of POSIX. In the FreeBSD
implementation, this only applies to accept(); accept4() does not copy
these properties, like Linux. As a result, accept4() is as portable as
possible but accept() is not exactly equivalent to any form of
accept4().
Furthermore, there is
Also, I don't know of any platform where
posix_spawn_file_actions_adddup2( ) can clear FD_CLOEXEC,
but posix_spawn_file_actions_adddup2() has in fact behaved that way in
FreeBSD's implementation since it was first committed (though this was
not documented until later).
I found some issues in bug411_atomic_CLOEXEC.pdf.
On page 2, there is
accept4(sock, addr, len, O_NONBLOCK)
which should at least be (but see below)
accept4(sock, addr, len, SOCK_NONBLOCK)
(Note that this mistake will not be detected on Linux/glibc because the
values are equal; however, on FreeBSD, the value of O_NONBLOCK is 4 and
the value of SOCK_SEQPACKET is 5, so SOCK_NONBLOCK cannot be equal to
O_NONBLOCK.)
Although O_NONBLOCK is the most common property where the difference is
apparent, BSD copies a few more properties to the new socket: the
O_ASYNC property and the signal destination as set by fcntl(F_SETOWN).
The latter property is also part of POSIX. In the FreeBSD
implementation, this only applies to accept(); accept4() does not copy
these properties, like Linux. As a result, accept4() is as portable as
possible but accept() is not exactly equivalent to any form of
accept4().
Furthermore, there is
Also, I don't know of any platform where
posix_spawn_file_actions_adddup2( ) can clear FD_CLOEXEC,
but posix_spawn_file_actions_adddup2() has in fact behaved that way in
FreeBSD's implementation since it was first committed (though this was
not documented until later).
--
Jilles Tjoelker
Jilles Tjoelker