cpp-subprocess
cpp-subprocess copied to clipboard
Busy looping when waiting for subprocess to finish
Hi,
I just noticed that my program is busy-looping and thus using up a lot of CPU resources while waiting for a subprocess to finish. I'm using the Popen class. The root cause seems to be that waitpid() is used with the WNOHANG option in the util::wait_for_child_exit(int pid) function.
Why is WNOHANG being used? Is there a way to avoid busy-looping while waiting for a subprocess to finish?
Better to add a usleep() to wait_for_child_exit() so the other issue about timeouts can be dealt with.