logoalt Hacker News

nine_ktoday at 3:47 AM3 repliesview on HN

POSIX signals are broken by design, alas: https://lwn.net/Articles/414618/

Python or not, almost nothing is safe inside a signal handler.


Replies

pjmlptoday at 6:08 AM

Exactly, the only safe thing to do in a signal is set a variable for other code to react on, also they completely mess up in multi-threaded code.

show 1 reply
knometoday at 4:01 AM

the first line of the article points out that python isn't run in the POSIX C handler. that just sets a flag for the interpreter to act on. the python issue is an unsafe re-entrant handling strategy in the interpreter.

inigyoutoday at 4:31 AM

Certain signals are true user-mode interrupts, like SIGTERM and some of the ones glibc uses to implement pthreads.

The ones related to application logic must only be handled with signalfd if you want any semblance of reliability.