In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/84f0440554c1fed2981f0ba8a4b2785919f5d734?hp=11883c88c2a3bf14fd6833153409e184d556438f>
- Log ----------------------------------------------------------------- commit 84f0440554c1fed2981f0ba8a4b2785919f5d734 Author: Jan Dubois <[email protected]> Date: Fri Mar 11 10:34:38 2011 -0800 Make sure json_pp is installed on Windows M win32/Makefile M win32/makefile.mk commit 82e24582a585cdcc94ac54b3e77a325e7aa89846 Author: Jan Dubois <[email protected]> Date: Fri Mar 11 10:30:11 2011 -0800 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 M t/op/fork.t M win32/win32.c ----------------------------------------------------------------------- Summary of changes: t/op/fork.t | 12 ++++++++++++ win32/Makefile | 3 ++- win32/makefile.mk | 3 ++- win32/win32.c | 7 +++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/t/op/fork.t b/t/op/fork.t index 3c40394..b8c03ab 100644 --- a/t/op/fork.t +++ b/t/op/fork.t @@ -452,3 +452,15 @@ EXPECT OPTION random child: called as [main::f(foo,bar)] waitpid() returned ok +######## +# Windows 2000: https://rt.cpan.org/Ticket/Display.html?id=66016#txn-908976 +system $^X, "-e", "if (\$pid=fork){sleep 1;kill(9, \$pid)} else {sleep 5}"; +print $?>>8, "\n"; +EXPECT +0 +######## +# Windows 7: https://rt.cpan.org/Ticket/Display.html?id=66016#txn-908976 +system $^X, "-e", "if (\$pid=fork){kill(9, \$pid)} else {sleep 5}"; +print $?>>8, "\n"; +EXPECT +0 diff --git a/win32/Makefile b/win32/Makefile index ea64959..e9ca59f 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -582,6 +582,7 @@ UTILS = \ ..\utils\cpan2dist \ ..\utils\shasum \ ..\utils\instmodsh \ + ..\utils\json_pp \ ..\x2p\find2perl \ ..\x2p\psed \ ..\x2p\s2p \ @@ -1168,7 +1169,7 @@ distclean: realclean perlvos.pod perlwin32.pod -cd ..\utils && del /f h2ph splain perlbug pl2pm c2ph pstruct h2xs \ perldoc perlivp dprofpp libnetcfg enc2xs piconv cpan *.bat \ - xsubpp instmodsh prove ptar ptardiff ptargrep cpanp-run-perl cpanp cpan2dist shasum corelist config_data + xsubpp instmodsh json_pp prove ptar ptardiff ptargrep cpanp-run-perl cpanp cpan2dist shasum corelist config_data -cd ..\x2p && del /f find2perl s2p psed *.bat -del /f ..\config.sh perlmain.c dlutils.c config.h.new \ perlmainst.c diff --git a/win32/makefile.mk b/win32/makefile.mk index e7a38ed..b62c27c 100644 --- a/win32/makefile.mk +++ b/win32/makefile.mk @@ -768,6 +768,7 @@ UTILS = \ ..\utils\cpan2dist \ ..\utils\shasum \ ..\utils\instmodsh \ + ..\utils\json_pp \ ..\x2p\find2perl \ ..\x2p\psed \ ..\x2p\s2p \ @@ -1554,7 +1555,7 @@ distclean: realclean perlvos.pod perlwin32.pod -cd ..\utils && del /f h2ph splain perlbug pl2pm c2ph pstruct h2xs \ perldoc perlivp dprofpp libnetcfg enc2xs piconv cpan *.bat \ - xsubpp instmodsh prove ptar ptardiff ptargrep cpanp-run-perl cpanp cpan2dist shasum corelist config_data + xsubpp instmodsh json_pp prove ptar ptardiff ptargrep cpanp-run-perl cpanp cpan2dist shasum corelist config_data -cd ..\x2p && del /f find2perl s2p psed *.bat -del /f ..\config.sh perlmain.c dlutils.c config.h.new \ perlmainst.c diff --git a/win32/win32.c b/win32/win32.c index 019e681..2394524 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1282,6 +1282,13 @@ win32_kill(int pid, int sig) case 9: /* kill -9 style un-graceful exit */ if (TerminateThread(hProcess, sig)) { + /* Allow the scheduler to finish cleaning up the other thread. + * Otherwise, if we ExitProcess() before another context switch + * happens we will end up with a process exit code of "sig" instead + * of our own exit status. + * See also: https://rt.cpan.org/Ticket/Display.html?id=66016#txn-908976 + */ + Sleep(0); remove_dead_pseudo_process(child); return 0; } -- Perl5 Master Repository
