News for hackers. Stuff that matters.
Re:Should you be scared of Unix signals? by pjc50 on Tuesday June 14, 2016 @08:16AM (#11901486)
Well, the brief was to "throw the whole thing out", including select (which is bad) and poll (which is merely adequate).

The machine traps are interesting in that they should only be generated locally - there's no sensible case for injecting SIGSEGV into other processes. Arguably we should learn from Windows "structured exception handling" here. There are two sensible things to do with traps (other than sudden death): hand over to a callback of some kind (which should be told about the state of the stack), or turn into a language-native exception and throw that.

Re:Should you be scared of Unix signals? by gpderetta on Tuesday June 14, 2016 @08:25AM (#11901530)
Poll is perfectly fine for the very large majority of unix applications which do not need to scale to tens of thousands of sockets.

The handling over to callback is exactly what is done by unix signals. Converting to exceptions can be implemented on top of signal handlers, but note that even MS stopped mapping by default structured exceptions to language exception a while ago, at least in C++, as unwinding the stack, destroying state and potentially calling destructors is the last thing you want on a segmentation fault or other unexpected events.

Re:Should you be scared of Unix signals? by pjc50 on Tuesday June 14, 2016 @10:34AM (#11902238)
The handling over to callback is exactly what is done by unix signals

Not quite, there are quite a lot of restrictions on what you can do in a signal handler. It ought to be possible to design a callback mechanism without those restrictions. And a signal tells you nothing about its origin or what file descriptor / child process etc. it might relate to.

Re:Should you be scared of Unix signals? by gpderetta on Tuesday June 14, 2016 @10:59AM (#11902389)
I assume that by restrictions you are talking about the async signal safety; this is inherent on the 'interrupt' nature of signals as they can happen at any point in a program execution, there is really no way around that. It would be of course nice if more functions where async signal safe (especially malloc).

Regarding the lack metadata, I agreed else thread that messages that carry such data ought to be transported via an explicit message queue, not via signals.