public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: windows exit codes truncated to 1 Byte
Date: Thu, 31 Mar 2016 18:50:00 -0000	[thread overview]
Message-ID: <20160331185002.GA3353@calimero.vinschen.de> (raw)
In-Reply-To: <56FD413A.9050502@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1857 bytes --]

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.

But...

> > POSIX specifies that the lower 8 bits of the exit status be made
> > available to the caller of wait/waitpid:
> > http://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html
> 
> 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
that...


Corinna

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-03-31 18:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1233154500.205789.1459429282664.JavaMail.yahoo.ref@mail.yahoo.com>
2016-03-31 13:04 ` Cristian
2016-03-31 13:31   ` Björn Stabel
2016-03-31 15:24     ` Eric Blake
2016-03-31 18:50       ` Corinna Vinschen [this message]
2016-03-31 18:58         ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160331185002.GA3353@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).