This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: windows exit codes truncated to 1 Byte

On Mar 31 09:24, Eric Blake wrote:
> On 03/31/2016 07:30 AM, BjÃrn Stabel wrote:
> > Am 31.03.2016 um 15:01 schrieb Cristian:
> >> I noted that exit codes returned by CMD and other apps (msiexec) are truncated to 1 byte (0 .. 255).
> This matches Linux, but not POSIX.

Why?  Does bash use waitid?

> >> Windows exit codes are represented using 32 bits, so is this limitation intentional?
> Part intentional (we do what Linux does), and part accidental (Cygwin
> handles the return status slightly different than Windows, and that
> handling makes it impossible to easily preserve all 32-bits, even if
> Linux were to be patched to obey POSIX).

I don't quite understand this.  Right now the exitcode value is
truncated to 8 bits to fit into the 32 bit status value as defined
for wait/waitpid, but this is not set in stone.  We could change
the communication between parent and child to allow preserving the
full 32 bit value for waitid.


> > POSIX specifies that the lower 8 bits of the exit status be made
> > available to the caller of wait/waitpid:
> >
> Correct: wait() and waitpid() can only return 8 bits; but POSIX states
> that waitid() MUST be able to access all 32-bits untruncated; this is
> where Linux gets it wrong (Linux truncates during exit(), so waitid()
> can only return 8 bits; other operating systems do NOT truncate during
> exit, but preserve all 32 bits; if you use wait() or waitpid() you only
> get 8 bits, but if you use waitid() you can see the full 32 bits).

...that only makes sense if we implement waitid at all.  SHTDI and all


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: signature.asc
Description: PGP signature

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]