#endif
break;
case '?':
- if (STATUS_POSIX == -1)
- sv_setiv(sv, (IV)-1);
- else
- sv_setuv(sv, (UV)STATUS_POSIX);
+ sv_setiv(sv, (IV)STATUS_POSIX);
break;
case '^':
s = IoTOP_NAME(GvIOp(defoutgv));
compiling.cop_arybase = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
break;
case '?':
- STATUS_POSIX_SET(SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv));
+ STATUS_POSIX_SET(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv));
break;
case '!':
SETERRNO(SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv),
#endif
#define STATUS_POSIX statusvalue
-#define STATUS_POSIX_SET(n) (statusvalue = (n))
+#define STATUS_POSIX_SET(n) \
+ STMT_START { \
+ statusvalue = (n); \
+ if (statusvalue != -1) \
+ statusvalue &= 0xFFFF; \
+ } STMT_END
#ifdef VMS
# define STATUS_NATIVE statusvalue_vms
# define STATUS_NATIVE STATUS_POSIX
# define STATUS_NATIVE_EXPORT STATUS_POSIX
# define STATUS_NATIVE_SET STATUS_POSIX_SET
-# define STATUS_ALL_SUCCESS STATUS_POSIX_SET(0)
-# define STATUS_ALL_FAILURE STATUS_POSIX_SET(1)
+# define STATUS_ALL_SUCCESS (statusvalue = 0)
+# define STATUS_ALL_FAILURE (statusvalue = 1)
#endif
#ifdef I_SYS_IOCTL
IEXT char * Iofmt; /* $# */
IEXT I32 Imaxsysfd IINIT(MAXSYSFD); /* top fd to pass to subprocesses */
IEXT int Imultiline; /* $*--do strings hold >1 line? */
-IEXT U32 Istatusvalue; /* $? */
+IEXT I32 Istatusvalue; /* $? */
#ifdef VMS
IEXT U32 Istatusvalue_vms; /* $^S */
#endif
} while (result == -1 && errno == EINTR);
(void)rsignal_restore(SIGINT, &ihand);
(void)rsignal_restore(SIGQUIT, &qhand);
- STATUS_NATIVE_SET(status);
- value = (result == -1) ? -1 : status;
+ STATUS_NATIVE_SET(result == -1 ? -1 : status);
do_execfree(); /* free any memory child malloced on vfork */
SP = ORIGMARK;
- PUSHi(value);
+ PUSHi(STATUS_POSIX);
RETURN;
}
if (op->op_flags & OPf_STACKED) {
STATUS_NATIVE_SET(value);
do_execfree();
SP = ORIGMARK;
- PUSHi(value);
+ PUSHi(STATUS_POSIX);
#endif /* !FORK or VMS */
RETURN;
}