GNU bug report logs - #6430
Emacs WINDOWS truncates exit status of processes to 8 bits

Previous Next

Package: emacs;

Reported by: macross84 <at> ozu.es

Date: Tue, 15 Jun 2010 17:29:01 UTC

Severity: wishlist

Tags: wontfix

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

Full log


Message #40 received at 6430 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Óscar Fuentes <ofv <at> wanadoo.es>
Cc: macross84 <at> ozu.es, 6430 <at> debbugs.gnu.org, npostavs <at> users.sourceforge.net
Subject: Re: bug#6430: Emacs WINDOWS truncates exit status of processes to 8
 bits
Date: Wed, 15 Jun 2016 20:32:43 +0300
> From: Óscar Fuentes <ofv <at> wanadoo.es>
> Cc: npostavs <at> users.sourceforge.net,  macross84 <at> ozu.es,  6430 <at> debbugs.gnu.org
> Date: Wed, 15 Jun 2016 19:14:25 +0200
> 
> Eli Zaretskii <eliz <at> 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.




This bug report was last modified 4 years and 240 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.