9 ms·
Except that once you do this, no one else can listen for that signal anymore. Pending signals go to the first to register for them, and then are no longer pendi
by kstenerud 5y ago
Except that once you do this, no one else can listen for that signal anymore. Pending signals go to the first to register for them, and then are no longer pending, so no one else gets notified. Aaaand you don't get notified of this problem - your registration call succeeds but you get nothing when a signal comes.
The Android runtime library uses similar tricks for ANRs, with similar problems.
Signals are probably the most broken of all POSIX APIs.
- matheusmoreira 5y ago> Except that once you do this, no one else can listen for that signal anymore. What do you mean by that? Who else is there other than the process being signaled? > Signals are probably the most broken of all POSIX APIs. I agree completely.
- kstenerud 5y ago>> Except that once you do this, no one else can listen for that signal anymore. > What do you mean by that? Who else is there other than the process being signaled? A library that needs to be notified of certain signals and perhaps also their contents.
- matheusmoreira 5y agoYeah, that's going to be a huge problem. Libraries shouldn't be doing that. They should leave signal handling to the caller and provide the functions that should be called in those cases. Just like memory allocation, initialization...
- kstenerud 5y agoWhich is great in theory, except that signal handlers are such an esoteric body of knowledge that very few people can do it at all, let alone do it properly. So, many libraries do it for them (which works so long as nobody uses the blocking or blocking-dependent APIs - which is generally true). Even the JVM taps SIGQUIT for dumping process info.
- R0b0t1 5y agoThe workaround for this you can find in SDL2 and some other libraries with event loops is having a default, library-provided setup routine and event loop. Know what you're doing? Set up signals yourself. Don't? Library sets it up for you.