Gisle Aas wrote: > The following trivial test program fails on AIX 5.1 because the high > bits are always stipped off $?. Does anybody know why perl does this?
Smells like non portable assumptions. As says perlvar, This is just the 16-bit status word returned by the wait() system call (or else is made up to look like it). > The following patch makes this test program succeed: > > --- perl.h.orig 2005-05-11 20:35:15.122448664 +0200 > +++ perl.h 2005-05-11 20:35:24.397536739 +0200 > @@ -2449,8 +2449,6 @@ > # define STATUS_POSIX_SET(n) \ > STMT_START { \ Surely STMT_START isn't necessary anymore. > PL_statusvalue = (n); \ PL_statusvalue is defined as 32 bits integer in intrpvar.h. wait(3) on Linux says that status is an "int". So your patch seems sane. Other opinions ? I also notice that you didn't touch the VMS definition of STATUS_POSIX_SET. I can't tell if this matters. > - if (PL_statusvalue != -1) \ > - PL_statusvalue &= 0xFFFF; \ > } STMT_END > # define STATUS_CURRENT STATUS_POSIX > # define STATUS_ALL_SUCCESS (PL_statusvalue = 0) > > and now the output is: > > $ ../t1/bin/perl xxx.pl > 1..2 > # $? = 983055 > ok 1 > ok 2 > > The perl test suite still passes both on AIX and Linux with this patch > applied. If nobody can explain the &=0xFFFF then I suggest we just > try to apply it and see what breaks. > > FYI: This is how WTERMSIG is defined in /usr/include/sys/wait.h on the > AIX machines we have here: > > AIX-4.3.3: #define WTERMSIG(__x) (int)(WIFSIGNALED(__x) ? ((__x) & 0x7f) > : -1) > AIX-5.1: #define WTERMSIG(__x) (int)(WIFSIGNALED(__x) ? ((((unsigned > int)__x) >> 16) & 0xff) : -1)