X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pp_sys.c;h=a95c43c94581903efc1560aa5fb3b398e13d471d;hb=ffb4440d02d1e8964757828cffb3de1e6f18ad0b;hp=4f3abe5cc1f357d119cec30dcd8e8f5dd2c9f1e1;hpb=5095244257e3c5d9389813ccbcd2187ff6e2e91f;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pp_sys.c b/pp_sys.c index 4f3abe5..a95c43c 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -508,7 +508,7 @@ PP(pp_open) djSP; dTARGET; GV *gv; SV *sv; - SV *name; + SV *name = Nullsv; I32 have_name = 0; char *tmps; STRLEN len; @@ -3738,7 +3738,12 @@ PP(pp_wait) 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 @@ -3757,7 +3762,12 @@ PP(pp_waitpid) 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 @@ -3858,6 +3868,8 @@ PP(pp_system) } PerlProc__exit(-1); #else /* ! FORK or VMS or OS/2 */ + PL_statusvalue = 0; + result = 0; if (PL_op->op_flags & OPf_STACKED) { SV *really = *++MARK; value = (I32)do_aspawn(really, (void **)MARK, (void **)SP); @@ -3867,10 +3879,12 @@ PP(pp_system) else { value = (I32)do_spawn(SvPVx(sv_mortalcopy(*SP), n_a)); } + if (PL_statusvalue == -1) /* hint that value must be returned as is */ + result = 1; STATUS_NATIVE_SET(value); do_execfree(); SP = ORIGMARK; - PUSHi(STATUS_CURRENT); + PUSHi(result ? value : STATUS_CURRENT); #endif /* !FORK or VMS */ RETURN; }