In POSIX there is no way to be notified via select
/poll
when a specific child process terminates. The closest you can get is a signal handler for SIGCHLD
, which interacts poorly with threads, might not be available at all in an interpreted language, and wakes you up when any child process terminates. Entering the land of system-specific extensions, signalfd
makes it easier to field SIGCHLD
from your main event loop but doesn't completely solve either the threads problem or the interpreted-language problem, and again it wakes you up when any child process terminates; I don't know of any others that address this problem.
Does any modern incarnation of Unix provide a mechanism whereby, in an 100% race-free and thread-safe manner, you can be awakened from a call to select
, poll
, or similar (epoll, kqueue, ...) when a specific child process terminates?