Get the latest tech news
Way too many ways to wait on a child process with a timeout
Published on 2024-11-10 Windows is not covered at all in this article. Discussions: /r/programming, HN, Lobsters I often need to launch a program in the terminal in a retry loop.
There is a degenerate case where the give command to run is wrong (e.g. typo in the parameters) or the executable does not exist, and our program will happily retry it to the bitter end. Evidently this is not a rare opinion, looking at the development in these areas: process descriptors, the various expansions to the venerable fork with vfork, clone, clone3, clone6, a bazillion different ways to do I/O multiplexing, etc. If you only care about MacOS and BSDs (or accept to use libkqueue on Linux), you can use kqueue because it works out of the box with PIDs, you avoid signals completely, and it's used in all the big libraries out of there e.g. libuv.
Or read this on Hacker News