summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2013-09-17 16:57:37 +1000
committerTony Cook <tony@develop-help.com>2013-09-17 16:57:37 +1000
commitd4c027436fbaf9384f42d7c7703b2499810ed39b (patch)
tree990501c865a5c8c62773669ca3fa54307ede2c31 /util.c
parent18603efee1e80bda2f6107c9569d056cb1071d4b (diff)
downloadperl-d4c027436fbaf9384f42d7c7703b2499810ed39b.tar.gz
[perl #85228] stop $!=EINVAL; waitpid(0,0) from looping
Diffstat (limited to 'util.c')
-rw-r--r--util.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/util.c b/util.c
index 79e4000df5..ef464f7d4d 100644
--- a/util.c
+++ b/util.c
@@ -2796,9 +2796,16 @@ Perl_wait4pid(pTHX_ Pid_t pid, int *statusp, int flags)
dVAR;
I32 result = 0;
PERL_ARGS_ASSERT_WAIT4PID;
- if (!pid)
- return -1;
#ifdef PERL_USES_PL_PIDSTATUS
+ if (!pid) {
+ /* PERL_USES_PL_PIDSTATUS is only defined when neither
+ waitpid() nor wait4() is available, or on OS/2, which
+ doesn't appear to support waiting for a progress group
+ member, so we can only treat a 0 pid as an unknown child.
+ */
+ errno = ECHILD;
+ return -1;
+ }
{
if (pid > 0) {
/* The keys in PL_pidstatus are now the raw 4 (or 8) bytes of the
@@ -2845,7 +2852,7 @@ Perl_wait4pid(pTHX_ Pid_t pid, int *statusp, int flags)
goto finish;
#endif
#if !defined(HAS_WAITPID) && defined(HAS_WAIT4)
- result = wait4((pid==-1)?0:pid,statusp,flags,NULL);
+ result = wait4(pid,statusp,flags,NULL);
goto finish;
#endif
#ifdef PERL_USES_PL_PIDSTATUS