develooper Front page | perl.perl5.porters | Postings from September 2005

$?>>8 vs. WEXITSTATUS

Thread Next
From:
Ken Hirsch
Date:
September 26, 2005 22:30
Subject:
$?>>8 vs. WEXITSTATUS
Message ID:
4338D8D1.5070207@ftml.net
There are a lot of places in the perl code that assume that $? >> 8 is 
the status code from exit(), which is true on most systems, but not 
all.  There's at least one POSIX-compatible system (MPE/iX) where this 
is not true. 

POSIX defines a macro WEXITSTATUS() to get the exit status.

Specifically, trying to build 5.9.3, these tests fail because of this 
problem:
  t/run/exit.t
  t/op/exec.t
  lib/Carp.t
  lib/ExtUtils/CBuilder/t/02-link.t
  lib/Pod/t/Usage.t
  t/pod/pod2usage2.t

One module that does it right is lib/Test/Harness/Straps.pm.

Is there a recommendation about using WEXITSTATUS?  Especially for 
modules included in the core distribution?

I realize that people would be reluctant to include dependencies on 
another module (POSIX) just for this one little item.  It does occur to 
me that perhaps, since system, fork/exec, exit, wait, and $? are all 
core functions, perhaps WEXITSTATUS should be too.

Ken Hirsch


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About