Subject: bug#19897: 24.3; Emacs exits with exit code 0 if EOF of stdin has been reached

From: Philipp Stephani <[email-masked]>
Date: Thu, 19 Feb 2015 11:47:25 +0000

Eli Zaretskii <[email-masked]> schrieb am Wed Feb 18 2015 at 10:16:29 PM:

> > From: Philipp Stephani <[email-masked]>
> > Date: Wed, 18 Feb 2015 21:58:42 +0100
> >
> > This has been discussed in
> > https://lists.gnu.org/archive/html/help-gnu-emacs/2015-02/msg00381.html.
> >
> > To reproduce:
> >
> > $ emacs -Q -batch -eval '(error "foo")' < /dev/null ; echo $?
> > foo
> > 255
> >
> > $ emacs -Q -batch -eval '(kill-emacs 37)' < /dev/null ; echo $?
> > 37
> >
> > $ emacs -Q -batch -eval '(progn (ignore-errors (read)) (kill-emacs 37))'
> <<< nil ; echo $?
> > Lisp expression: 37
> >
> > $ emacs -Q -batch -eval '(read)' < /dev/null ; echo $?
> > Lisp expression: Error reading from stdin
> > 0
> >
> > $ emacs -Q -batch -eval '(progn (ignore-errors (read)) (kill-emacs 37))'
> < /dev/null ; echo $?
> > Lisp expression: 0
> >
> > The examples with nonzero exit code are as expected.  The examples with
> > zero exit code are unexpected.  They are caused by the code
> >
> >   if (feof (stdin))
> >     arg = Qt;
> >
> > in Fkill_emacs.  This behavior confuses e.g. unit tests runners that
> > rely on a precise exit code.
> > It is not documented in the documentation for kill-emacs.
>
> Fixed in commit 7932d06 on master branch.
>

Thanks for the speedy fix. Confirming that this fixes my problem.