Still, adding some sleep after a successful kill, or even after a successful os.waitpid, prevents the failure.
It's as if os.waitpid(pid, os.WNOHANG) is returning success before the child has been able to clean up the pidfile.
Still, adding some sleep after a successful kill, or even after a successful os.waitpid, prevents the failure.
It's as if os.waitpid(pid, os.WNOHANG) is returning success before the child has been able to clean up the pidfile.