Mail Archives: djgpp-workers/2003/02/26/14:40:03
Hello.
When I was testing out the DJGPP port of autoconf 2.57 with Perl 5.6.1, I
noticed that POSIX::WEXITSTATUS was broken. I think I've just discovered the
problem.
DJGPP's W* macros in <sys/wait.h> expect the program return code to be
returned in the lower 8 bits of the status variable from wait*. This is
different to, say, Linux, where the return code is expected to be in bits 8-15
(from <bits/waitstatus.h> on my RedHat Linux 6.2 box).
Perl's "system" call returns the exit status in bits 8-15 of the return value.
It is described on "man perlfunc" as the return value of the wait system call.
Since DJGPP doesn't have a working wait call, the DJGPP port of Perl has a
load of code that uses system() and converts the return code of system() from
the DJGPP format to the Perl format.
$? is the "status returned by the last pipe close" (see "man perlvar"), which
can be the status of the last call to Perl's "system" call.
POSIX::WEXITSTATUS($foo) returns the result of the C macro WEXITSTATUS on the
variable $foo.
The problem is that the Perl format is not the same as the format used by the
WEXITSTATUS, etc. macros from DJGPP's <sys/wait.h>. So when you do
POSIX::WEXITSTATUS($?), to get the return code of the last program, there's a
mismatch.
There seem to be two solutions:
1. Make POSIX::WEXITSTATUS (and the other POSIX:W*) do something special for
DJGPP, to cope with the inconsistency between the return code of Perl's
"system" call and POSIX::W*.
2. DJGPP doesn't have working wait*. So we can make W* from <sys/wait.h>
compatible with Linux (and other Unices, I'm guessing) without breaking
anything. I.e.: follow the Unix Way.
Solution 1 will fix the build with DJGPP 2.03. I think we should adopt
solution 2 for DJGPP 2.04.
Does this make sense? Does anyone agree/disagree with the solutions?
Thanks, bye, Rich =]
--
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]
- Raw text -