This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #119893] avoid waiting on pid 0
authorTony Cook <tony@develop-help.com>
Thu, 17 Oct 2013 04:29:58 +0000 (15:29 +1100)
committerTony Cook <tony@develop-help.com>
Thu, 17 Oct 2013 04:43:09 +0000 (15:43 +1100)
commite9d373c4fc63458e812eaac6aef324f1b45fd607
tree8541974202ab72f8cd6d214ae44e47cc9a1ebe8c
parentf2a7d0fc9f4d388e4bb0628fba2476c2789721c8
[perl #119893] avoid waiting on pid 0

When a filehandle is cloned into a standard handle, do_openn() copies
the pid from the original handle in PL_fdpid to the standard handle
and zeroes the entry for the original handle, so when the original
handle was closed Perl_my_pclose() would call wait4pid() with a pid of 0.

With v5.19.3-614-gd4c0274 I modified wait4pid(), perl's waitpid/wait4()
wrapper, to allow a pid of zero through to the actual system call when
available.

These combined so that following v5.19.3-614-gd4c0274 in some
circumstances closing the original handle would block by calling
waitpid(0, ...) or wait4(0, ...), which waits for any child process in
the same process group to terminate.

This commit changes Perl_my_pclose() to wait for the child only when
the stored pid is positive.
MANIFEST
t/io/closepid.t [new file with mode: 0644]
util.c