Mail Archives: djgpp-workers/2003/02/26/14:40:03

Sender: rich AT phekda DOT freeserve DOT co DOT uk
Message-ID: <>
Date: Wed, 26 Feb 2003 19:38:06 +0000
From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.23 i586)
X-Accept-Language: de,fr
MIME-Version: 1.0
To: Laszlo Molnar <laszlo DOT molnar AT eth DOT ericsson DOT se>,
DJGPP workers <djgpp-workers AT delorie DOT com>
Subject: DJGPP port of Perl 5.6.1 & POSIX::WEXITSTATUS
Reply-To: djgpp-workers AT delorie DOT com


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

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

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 [ ]

- Raw text -

  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019