Positions forming in the Debian init system discussion
Positions forming in the Debian init system discussion
Posted Jan 2, 2014 1:05 UTC (Thu) by wahern (subscriber, #37304)In reply to: Positions forming in the Debian init system discussion by Cyberax
Parent article: Positions forming in the Debian init system discussion
Likewise, on Linux signalfd will not catch ignored or delivered signals (that is, signals with a handler). You have to block the signal in order to use signalfd to see it. This is not so on *BSD.
eventfd is nice, though. If you're using it as a true counting semaphore, there's no substitute. Most people usually use it in place of a signaling pipe, however, in which case it's trivial to just use a pipe.
Posted Jan 2, 2014 1:34 UTC (Thu)
by wahern (subscriber, #37304)
[Link]
Solaris, OTOH, has no signal listening primitive, which is really annoying. OTOH, it's O(1) polling primitive is always one-shot, which sounds less than optimal but is really very smart. They can optimize persistence behind the scenes while avoiding threading+event pitfalls that plague modern software.
Posted Jan 2, 2014 9:38 UTC (Thu)
by smurf (subscriber, #17840)
[Link] (4 responses)
OTOH if you have a bundle of possible signal handlers in BSD (multiple worker threads for instance), that's easy too, just write a signal handler which triggers the next-available thread.
I cannot imagine a situation where sending a signal to both a traditional handler and signalfd would make sense. If warranted, the signalfd reader can call the traditional handler explicitly. But to have the kernel do that by default seems foolish to me.
Posted Jan 2, 2014 20:42 UTC (Thu)
by wahern (subscriber, #37304)
[Link]
On Linux you have to create a special-purposed centralized signal dispatcher in your library to do this. Not on BSD.
On Linux creating this centralized signal dispatcher forces you, as a library writer, to have to initialize and maintain a global state object. This is exceptionally ugly. I chose not to do that, because my library is meant to be embeddable (including trivially pluggable into any event loop) and guaranteed not to do crazy things behind the hosting application's back (that means no hidden mutexes, for example, which might complicate forking or create unnecessary dependencies).
So, I'm sorry, there's no excuse here. I understand why Linux did it--because it requires hacking up the signal dispatching code in the kernel to support multiple receivers. But *BSD put in the effort, and they have a better interface to show for it.
On the flip side, Linux has eventfd and *BSD doesn't. Linux has the better interface in this regard for pollable, counting semaphores. No excuses.
Posted Jan 2, 2014 23:38 UTC (Thu)
by sionescu (subscriber, #59410)
[Link] (2 responses)
Posted Jan 3, 2014 21:57 UTC (Fri)
by smurf (subscriber, #17840)
[Link] (1 responses)
In any case I consider a library's dependency on SIGCHLD delivery (or indeed the fact that it installs a SIGCHLD handler at all) to be a bug. There are more reliable methods to get notified when a process has gone away, e.g. when reading from its STDERR returns EOF.
Posted Jan 4, 2014 1:51 UTC (Sat)
by wahern (subscriber, #37304)
[Link]
On BSD you could listen for SIGCHLD with kevent+EVFILT_SIGNAL on two seperate kqueue descriptors, reap with wait4 or waitpid, and there'd be no race whatsoever.
Positions forming in the Debian init system discussion
Positions forming in the Debian init system discussion
Positions forming in the Debian init system discussion
Positions forming in the Debian init system discussion
Positions forming in the Debian init system discussion
Positions forming in the Debian init system discussion
