|
Message-ID: <20130409153936.GW20323@brightrain.aerifal.cx> Date: Tue, 9 Apr 2013 11:39:36 -0400 From: Rich Felker <dalias@...ifal.cx> To: Laurent Bercot <ska-skaware@...rnet.org> 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). I don't know if you got my last email, because somehow when I hit reply-to-all it went to your list (where it was held as moderated) but not your personal address. So I'm repeating it here: ---------------------------------------------------------------------- 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. ---------------------------------------------------------------------- I did think of one additional thing I want to ask about though: does setting non-blocking mode even via fcntl after the fd is obtained fail to work properly on old kernels? If so, then I agree we should fail the call if SFD_NONBLOCK was specified and signalfd4 returns -ENOSYS. Can you let me know what the situation is and whether this issue, or any other issue I might not be aware of, applies? 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.