Subject: bug#6430: Emacs WINDOWS truncates exit status of processes to 8 bits

From: Noam Postavsky <[email-masked]>
Date: Tue, 14 Jun 2016 17:48:22 -0400

On Tue, Jun 14, 2016 at 10:35 AM, Eli Zaretskii <[email-masked]> wrote:
> All the above is true, but I don't understand the original complaint.

My understanding of the original complaint is that if you compile the
program below:

#include <stdlib.h>

int main(int argc, char *argv[])
{
    return atoi(argv[1]);
}

/*
(call-process (expand-file-name "exit-arg1.exe") nil nil nil "300") ;=> 44
 */

To lisp programs the exit status gets truncated to 8 bits, whereas
running from cmd.exe:

C:\Users\npostavs\src\emacs\bug-6430-w32-exit-rc>exit-arg1.exe 300

C:\Users\npostavs\src\emacs\bug-6430-w32-exit-rc>echo %errorlevel%
300

> Emacs doesn't truncate exit status of subprocesses in any way, it
> retrieves the full value of the status, and then reformats it
> according to what the Posix-style WIF* macros (which Emacs uses
> elsewhere) expect.  No information is lost during this reformatting,
> see the implementation of waitpid in w32proc.c.

Not really sure what this reformatting is about, but I think the point
is that the original value does not return to lisp.