djSP; dTARGET;
GV *gv;
SV *sv;
- SV *name;
+ SV *name = Nullsv;
I32 have_name = 0;
char *tmps;
STRLEN len;
IoIFP(rstio) = PerlIO_fdopen(fd[0], "r");
IoOFP(wstio) = PerlIO_fdopen(fd[1], "w");
IoIFP(wstio) = IoOFP(wstio);
- IoTYPE(rstio) = '<';
- IoTYPE(wstio) = '>';
+ IoTYPE(rstio) = IoTYPE_RDONLY;
+ IoTYPE(wstio) = IoTYPE_WRONLY;
if (!IoIFP(rstio) || !IoOFP(wstio)) {
if (IoIFP(rstio)) PerlIO_close(IoIFP(rstio));
}
if (PL_op->op_type == OP_SYSREAD) {
#ifdef PERL_SOCK_SYSREAD_IS_RECV
- if (IoTYPE(io) == 's') {
+ if (IoTYPE(io) == IoTYPE_SOCKET) {
length = PerlSock_recv(PerlIO_fileno(IoIFP(io)),
buffer+offset, length, 0);
}
}
else
#ifdef HAS_SOCKET__bad_code_maybe
- if (IoTYPE(io) == 's') {
+ if (IoTYPE(io) == IoTYPE_SOCKET) {
char namebuf[MAXPATHLEN];
#if defined(VMS_DO_SOCKETS) && defined(DECCRTL_SOCKETS)
bufsize = sizeof (struct sockaddr_in);
length = -1;
}
if (length < 0) {
- if ((IoTYPE(io) == '>' || IoIFP(io) == PerlIO_stdout()
+ if ((IoTYPE(io) == IoTYPE_WRONLY || IoIFP(io) == PerlIO_stdout()
|| IoIFP(io) == PerlIO_stderr()) && ckWARN(WARN_IO))
{
/* integrate with report_evil_fh()? */
if (length > blen - offset)
length = blen - offset;
#ifdef PERL_SOCK_SYSWRITE_IS_SEND
- if (IoTYPE(io) == 's') {
+ if (IoTYPE(io) == IoTYPE_SOCKET) {
retval = PerlSock_send(PerlIO_fileno(IoIFP(io)),
buffer+offset, length, 0);
}
RETPUSHUNDEF;
IoIFP(io) = PerlIO_fdopen(fd, "r"); /* stdio gets confused about sockets */
IoOFP(io) = PerlIO_fdopen(fd, "w");
- IoTYPE(io) = 's';
+ IoTYPE(io) = IoTYPE_SOCKET;
if (!IoIFP(io) || !IoOFP(io)) {
if (IoIFP(io)) PerlIO_close(IoIFP(io));
if (IoOFP(io)) PerlIO_close(IoOFP(io));
RETPUSHUNDEF;
IoIFP(io1) = PerlIO_fdopen(fd[0], "r");
IoOFP(io1) = PerlIO_fdopen(fd[0], "w");
- IoTYPE(io1) = 's';
+ IoTYPE(io1) = IoTYPE_SOCKET;
IoIFP(io2) = PerlIO_fdopen(fd[1], "r");
IoOFP(io2) = PerlIO_fdopen(fd[1], "w");
- IoTYPE(io2) = 's';
+ IoTYPE(io2) = IoTYPE_SOCKET;
if (!IoIFP(io1) || !IoOFP(io1) || !IoIFP(io2) || !IoOFP(io2)) {
if (IoIFP(io1)) PerlIO_close(IoIFP(io1));
if (IoOFP(io1)) PerlIO_close(IoOFP(io1));
goto badexit;
IoIFP(nstio) = PerlIO_fdopen(fd, "r");
IoOFP(nstio) = PerlIO_fdopen(fd, "w");
- IoTYPE(nstio) = 's';
+ IoTYPE(nstio) = IoTYPE_SOCKET;
if (!IoIFP(nstio) || !IoOFP(nstio)) {
if (IoIFP(nstio)) PerlIO_close(IoIFP(nstio));
if (IoOFP(nstio)) PerlIO_close(IoOFP(nstio));
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
}
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);
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;
}