Date: Mon, 8 Apr 2013 10:40:06 -0400 From: Rich Felker <dalias@...ifal.cx> To: skaware@...t.skarnet.org, dalias@...ifal.cx Cc: musl@...ts.openwall.com Subject: Re: musl signalfd (was: selfpipe + musl libc info) On Mon, Apr 08, 2013 at 07:52:31AM +0200, Laurent Bercot wrote: > Thanks David. > And Rich, thanks for patching musl. However, I think your workaround for > pre-2.6.27 kernels is unneeded, if not downright incorrect. > > The signalfd(2) manpage says: "In Linux up to version 2.6.26, the flags > argument is unused, and must be specified as zero." > And also: > "ERRORS > EINVAL flags is invalid; or, in Linux 2.6.26 or earlier, flags is nonzero." > > The current musl patch actually honors the flags with a race condition. > Instead, returning -1 EINVAL if the signalfd4 syscall does not exist but > flags is nonzero is the safer thing to do - and is what the manpage > specifies. > > The skalibs signalfd autodetection test actually relies on this. It > tests the signalfd() libc call with a SFD_NONBLOCK flags argument; if > the call fails for any reason, skalibs will not use signalfd at all > (and implement selfpipe via a real self-pipe). This makes no sense. For SFD_NONBLOCK, setting it atomically does not matter; the application could just fallback to setting it with fcntl if opening it with the nonblocking flag failed. Falling back to using a pipe in that situation makes no sense. If the issue were SFD_CLOEXEC, non-atomicity is a problem, but there is no way to fallback anyway. Using a pipe would still have the same non-atomicity issue. If you think there are situations where the application really could work around the lack of these kernel features, please explain. I'm open to changing things but I want a good justification. Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.