* It's not necessary to do waitpid(pid, os.WNOHANG) followed by
kill(pid, 0); the return value from waitpid() will be (0, 0) when
the process has not exited yet, and it will error the same as kill()
if the process does not exist.
* It might be nice to be able to pass a subprocess.Popen into
two_stage_kill, so that its poll() method is used, and so the
returncode attribute is set correctly to avoid confusion. But,
really, this is probably not worth the effort.
Looks good. Two comments:
* It's not necessary to do waitpid(pid, os.WNOHANG) followed by
kill(pid, 0); the return value from waitpid() will be (0, 0) when
the process has not exited yet, and it will error the same as kill()
if the process does not exist.
* It might be nice to be able to pass a subprocess.Popen into
two_stage_kill, so that its poll() method is used, and so the
returncode attribute is set correctly to avoid confusion. But,
really, this is probably not worth the effort.