-
-
Notifications
You must be signed in to change notification settings - Fork 154
Signal Handling in Oil
andychu edited this page Jun 12, 2019
·
14 revisions
Handling signals in Python exposes you to EINTR.
See PEP 475 -- Retry system calls failing with EINTR. We're backporting this work. That's the main purpose of the native/posixmodule.c
fork (in addition to removing over 7,000 lines of unused code).
Signals Oil cares about:
- SIGWINCH -- to get notified about Window size changes
- ... TODO
-
demo/eintr.sh
in the repository
(This section isn't strictly related to Oil)
- Signals and multithreading
- This blog post and related comments are show much confusion there are https://news.ycombinator.com/item?id=9564975
- The author
- In interpreters
- Any nontrivial logic must be run on the main thread, not in the signal handler. So interpreters queue signal handlers for running on the main loop. (I think bash only changed this recently, but Python has always done this.) This means that signal handling can get arbitrarily delayed. Maybe not a big problem in practice?
- API issues
- Signals can be coalesced. e.g. When you get
SIGCHLD
, you have to callos.wait()
multiple times to get multiple notifications. What about other signals? - Simultaneously waiting for both a signal and an event on a file descriptor. Solution: "the self-pipe trick".
- When a Python program starts to handle signals, now it must handle EINTR (in Python 2.7).
- This is also true of C programs, though I'm not sure.
- Signals can be coalesced. e.g. When you get