by bmalehorn · 10y ago · 0 comments
It's like discovering that "ls" is spawning 5 threads for internal communication.
In particular there is no sane way to async waitpid() on POSIX.
... I'm not sure I can disagree with "no sane way".
In fact, I challenge you to solve the problem "spawn process; waitpid for 15 seconds; otherwise kill hard" in Rust (or C++ if you feel like) on POSIX once with threads and once without threads by sticking to what's permitted in the standard and so that multiple processes can be waited for.
Then also measure CPU impact :)
This is false, you can call any async signal safe function. Incidentally write is one of them.
Another trick is the close-on-exit pipe.
https://play.rust-lang.org/?gist=ba4802a59f462cb8bce0c1bac92...
It would be significantly simpler with sigwaitinfo() if you didn't care to do a real select loop, but I assume most programs want a real select (or poll/epoll/whatever) loop.