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.
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".