t/op/utftaint.t See if utf8 and taint work together
t/op/vec.t See if vectors work
t/op/ver.t See if v-strings and the %v format flag work
+t/op/waitpid.t See if waitpid works
t/op/wantarray.t See if wantarray works
t/op/warn.t See if warn works
t/op/while.t See if while loops work
--- /dev/null
+#!./perl
+
+# tests for (possibly emulated) waitpid
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ require './test.pl';
+ require Config;
+ skip_all('no Errno')
+ unless eval 'use Errno qw(EINVAL); 1';
+ skip_all('no POSIX')
+ unless eval 'use POSIX qw(WNOHANG); 1';
+}
+
+$|=1;
+
+watchdog(10);
+{
+ # [perl #85228] Broken waitpid
+ # $! = EINVAL; waitpid 0, 0; # would loop forever, even with WNOHANG
+ $! = EINVAL;
+ my $pid = waitpid(0, WNOHANG);
+
+ # depending on the platform, there's several possible values for
+ # $pid and $!, so I'm only testing that we don't loop forever.
+ #
+ # Some of the complications are:
+ #
+ # - watchdog() may be implemented with alarm() or fork, so there
+ # may or may not be children (this code doesn't use threads, so
+ # threads shouldn't be used)
+ #
+ # - the platform may or may not implement waitpid()/wait4()
+
+ pass("didn't block on waitpid(0, ...)");
+}
+
+done_testing();
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
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