|
|
|
|
|
by jforberg
2551 days ago
|
|
This discussion seems to ignore the fact that being blocked in a "long-running system call" is the normal state for many (most?) Unix services. If you look at `ps ax` on your system, you'll likely see about a hundred processes. But if you look at `top`, you'll see only a handful of processes having non-zero CPU usage. Why? Because most processes are just waiting (in a system call) for something to do. A web server is blocked in a select/poll/epoll() call waiting for a connection. Your shell is blocked in a read() call waiting for you to type something. This is just the normal way that a main loop is implemented on Unix. When you kill one of these processes, they need a way to break out of their loop and with the EINTR approach, they get a chance to break and exit. I'm far from convinced that a "majority" of services want to just catch signals and carry on. |
|
Recognizing EINTR at the program level isn't required for this kind of shutdown. I think the system call will only return if the signal is ignored or if the signal handler returns, but you would only do this if you thought you had recovered from the error.