This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In t/op/getppid.t remove most race conditions by signaling using pipes.
authorNicholas Clark <nick@ccl4.org>
Fri, 1 Jun 2012 13:40:51 +0000 (15:40 +0200)
committerNicholas Clark <nick@ccl4.org>
Sat, 2 Jun 2012 10:39:13 +0000 (12:39 +0200)
commit7285a48a38e9b0d329d9f45cdbca473adedc9c1e
treea7db847bdcf229ff61acbfddb13842c2371958d2
parenta374d15c344afad9e9067bbca3d0db156963ae47
In t/op/getppid.t remove most race conditions by signaling using pipes.

Previously t/op/getppid.t used sleep calls in the child and grandchild to
(attempt to) sequence actions between them. This was a subtle race condition,
which could come unstuck on busy systems causing spurious test failures.

Instead use EOF on pipes as a cheap portable way to synchronise between
processes. This eliminates one sleep call completely. Unfortunately, we can't
completely eliminate the other, as the grandchild spots that the child's
exit has closed the pipe *before* the child completely exits. Hence retain
the sleep to (usually) give time for the child to completely exit. This
reduces the race condition to "sleep 2" vs "child finishes exiting", which
is much less than the previous race condition of "sleep 2" vs "child does
everything from returning from fork to exiting".
t/op/getppid.t