Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>This is exactly why signals are process-global instead of thread-local.

Signals can be sent either to a process or to a specific thread under linux. Signals sent to the process are handled by an arbitrary thread. There's a bunch of gotchas and whatnot past that.

Mixing signals and threads is pretty much trash.



> Mixing signals and threads is pretty much trash.

Agreed, except for SIGSEGV, SIGBUS, and SIGPIPE, which are guaranteed to be delivered, if at all, to the thread which triggered the condition. (Unless, of course, they were raised explicitly.) Still trash in the sense that to do it right you're depending on installing global signal handlers and (very likely) arranging for thread-local storage (actual TLS isn't even async-signal safe; see my post elsethread regarding the sigaltstack trick), so these tricks are really only practical for the core application and not something you can stash in a library to perform transparently.

FWIW, none of this behavior is specific to Linux. Linux follows POSIX rather well in this regard.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: