int argflags;
childpid = wait4pid(-1, &argflags, 0);
+# if defined(USE_ITHREADS) && defined(PERL_IMPLICIT_SYS)
+ /* 0 and -1 are both error returns (the former applies to WNOHANG case) */
+ STATUS_NATIVE_SET((childpid && childpid != -1) ? argflags : -1);
+# else
STATUS_NATIVE_SET((childpid > 0) ? argflags : -1);
+# endif
XPUSHi(childpid);
RETURN;
#else
optype = POPi;
childpid = TOPi;
childpid = wait4pid(childpid, &argflags, optype);
+# if defined(USE_ITHREADS) && defined(PERL_IMPLICIT_SYS)
+ /* 0 and -1 are both error returns (the former applies to WNOHANG case) */
+ STATUS_NATIVE_SET((childpid && childpid != -1) ? argflags : -1);
+# else
STATUS_NATIVE_SET((childpid > 0) ? argflags : -1);
+# endif
SETi(childpid);
RETURN;
#else
EXPECT
pipe_from_fork
pipe_to_fork
+########
+if ($pid = fork()) {
+ print "forked first kid\n";
+ print "waitpid() returned ok\n" if waitpid($pid,0) == $pid;
+}
+else {
+ print "first child\n";
+ exit(0);
+}
+if ($pid = fork()) {
+ print "forked second kid\n";
+ print "wait() returned ok\n" if wait() == $pid;
+}
+else {
+ print "second child\n";
+ exit(0);
+}
+EXPECT
+forked first kid
+first child
+waitpid() returned ok
+forked second kid
+second child
+wait() returned ok
if (!pid)
return -1;
+#if !defined(HAS_WAITPID) && !defined(HAS_WAIT4) || defined(HAS_WAITPID_RUNTIME)
if (pid > 0) {
sprintf(spid, "%"IVdf, (IV)pid);
svp = hv_fetch(PL_pidstatus,spid,strlen(spid),FALSE);
return pid;
}
}
+#endif
#ifdef HAS_WAITPID
# ifdef HAS_WAITPID_RUNTIME
if (!HAS_WAITPID_RUNTIME)
*status = (int)((waitcode & 0xff) << 8);
retval = (int)w32_pseudo_child_pids[child];
remove_dead_pseudo_process(child);
- return retval;
+ return -retval;
}
}
else
*status = (int)((exitcode & 0xff) << 8);
retval = (int)w32_pseudo_child_pids[i];
remove_dead_pseudo_process(i);
- return retval;
+ return -retval;
}
}
}