all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "Óscar Fuentes" <ofv@wanadoo.es>
Cc: macross84@ozu.es, 6430@debbugs.gnu.org, npostavs@users.sourceforge.net
Subject: bug#6430: Emacs WINDOWS truncates exit status of processes to 8 bits
Date: Wed, 15 Jun 2016 20:32:43 +0300	[thread overview]
Message-ID: <83shwecq84.fsf@gnu.org> (raw)
In-Reply-To: <87eg7yjrwu.fsf@wanadoo.es> (message from Óscar Fuentes on Wed, 15 Jun 2016 19:14:25 +0200)

> From: Óscar Fuentes <ofv@wanadoo.es>
> Cc: npostavs@users.sourceforge.net,  macross84@ozu.es,  6430@debbugs.gnu.org
> Date: Wed, 15 Jun 2016 19:14:25 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> > GetLastError has nothing to do with this, because it's not an API that
> >> > fails, it's a program that exits with some arbitrary exit code.
> >> 
> >> if( ! CreateProcess(....) ) {
> >>   DWORD ec = GetLastError();
> >>   // do some cleanup
> >>   ExitProcess(ec);
> >> }
> >
> > That's not how Emacs does that, see waitpid and its callers.
> 
> Once again, we are miscommunicating. AFAIU this is about Emacs calling a
> process foo which returns an exit code larger than 255, but Emacs only
> reports the lower 8 bits to the Elisp function that started the process.
> 
> In w32proc.c waitpid:
> 
>   if (!GetExitCodeProcess (wait_hnd[active], &retval))
>   ...
>   retval <<= 8;
> 
> Windows applications make use of the full 32 bits of the return code.
> With Emacs it is impossible to know those larger-than-255 exit codes.

But not because of the code you cite: the 8-bit left shift just means
we can report 24 bits out of 32.  And all of that is completely
unrelated to GetLastError, because errors in starting the subprocess
are not reported via waitpid.

Once again, if this is important (I don't think so), we can redefine
WEXITSTATUS etc. macros to keep all the 32 bits of the exit status
(actually, the top 2 bits are reserved, so only 30 bits can be used).
Feel free to submit patches to that effect if you like.





  reply	other threads:[~2016-06-15 17:32 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-15 17:20 bug#6430: Emacs WINDOWS truncates exit status of processes to 8 bits macross84
2016-06-14  2:48 ` Noam Postavsky
2016-06-14 13:07   ` Óscar Fuentes
2016-06-14 14:35   ` Eli Zaretskii
2016-06-14 21:48     ` Noam Postavsky
2016-06-15  2:39       ` Eli Zaretskii
2016-06-15 12:30         ` Óscar Fuentes
2016-06-15 15:02           ` Eli Zaretskii
2016-06-15 15:15             ` Óscar Fuentes
2016-06-15 15:40               ` Eli Zaretskii
2016-06-15 17:14                 ` Óscar Fuentes
2016-06-15 17:32                   ` Eli Zaretskii [this message]
2016-06-15 17:36                     ` Óscar Fuentes
2016-06-15 18:04                       ` Eli Zaretskii
2016-06-15 18:22                         ` Óscar Fuentes
2016-06-15 18:50                           ` Eli Zaretskii
2016-06-15 19:32                             ` Óscar Fuentes
2016-06-16  2:35                               ` Eli Zaretskii
2016-06-16  4:13                                 ` Óscar Fuentes
2016-06-16 15:07                                   ` Eli Zaretskii
2016-06-16 17:56                                     ` Óscar Fuentes
2016-06-16 19:05                                       ` Eli Zaretskii
2020-11-19  4:05                                         ` Stefan Kangas

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=83shwecq84.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=6430@debbugs.gnu.org \
    --cc=macross84@ozu.es \
    --cc=npostavs@users.sourceforge.net \
    --cc=ofv@wanadoo.es \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.