This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Avoid race codition when setting process exit code on Windows.
authorJan Dubois <jand@activestate.com>
Fri, 11 Mar 2011 18:30:11 +0000 (10:30 -0800)
committerJan Dubois <jand@activestate.com>
Fri, 11 Mar 2011 18:30:11 +0000 (10:30 -0800)
commit82e24582a585cdcc94ac54b3e77a325e7aa89846
tree8c932f89f536cd98d2c70b43e054ab14049e6fbf
parent11883c88c2a3bf14fd6833153409e184d556438f
Avoid race codition when setting process exit code on Windows.

A Perl program using fork() emulation on Windows may end up
kill()ing the forked child and exiting immediately.  There
is a race condition where the process exit code may be
changed to '9' (the signal used to kill the child thread),
overriding the value the parent thread used in ExitProcess()
(called implicitly with the return value of main()).

Giving up the remainder of the time-slice after terminating
a child thread seems to eliminate this race.

This bug is responsible for various CPAN test failures,
where all tests seem to pass, but Test::Harness still
reports: "Dubious, test returned 9 (wstat 2304, 0x900)"
(e.g. HTTP-Server-Simple, tests based on Test-TCP).

See also https://rt.cpan.org/Ticket/Display.html?id=66016#txn-908976
t/op/fork.t
win32/win32.c