Skip Menu |

This queue is for tickets about the Proc-Simple CPAN distribution.

Report information
The Basics
Id: 69782
Status: open
Priority: 0/
Queue: Proc-Simple

People
Owner: Nobody in particular
Requestors: zefram [...] fysh.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: sh-c test randomly fails
Date: Mon, 25 Jul 2011 11:47:23 +0100
To: bug-Proc-Simple [...] rt.cpan.org
From: Zefram <zefram [...] fysh.org>
Proc::Simple's sh-c.t test for support for running shell commands is faulty, suffering from a race condition. Specifically: after SIGTERMing the subordinate process group, it waits for its immediate child to terminate, then expects that the flag file has been removed. However, its immediate child is the shell process, whereas the flag file is removed by the SIGTERM handler of its grandchild, which it doesn't wait for. So the test may pass or fail, randomly, depending on how soon the grandchild's SIGTERM handler runs relative to when the immediate chald terminates and the parent notices. The chance of this false failure can be massively reduced by adding a "sleep 1" immediately before the final test for whether the flag file was unlinked. Alternatively, you could use another mechanism (second flag file, or kill(0,$pid) with the PID determined by other means) to wait until the grandchild has terminated (one way or another) before checking that its SIGTERM handler was run. -zefram
Good catch, thanks for reporting your findings. I've applied a patch: https://github.com/mschilli/proc-simple-perl/tree/035861a670553353163b3b83a63a16faeaefc8ad then fixed (hopefully) another nasty race condition: https://github.com/mschilli/proc-simple-perl/commit/12cb805e5fdbc66a78370ef460b55e014000c2f6 and then released Proc::Simple 1.30. Let me know if you find anything fishy. -- Mike
Meh, on the other hand, the previous fix might leave a subprocess unkilled, here's a better fix: https://github.com/mschilli/proc-simple-perl/commit/10eef5b8b0028371bf52fbda6763fb02b25d6f12