help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Weird behavior of kill-emacs


From: Eli Zaretskii
Subject: Re: Weird behavior of kill-emacs
Date: Wed, 18 Feb 2015 21:18:14 +0200

> From: Philipp Stephani <address@hidden>
> Date: Wed, 18 Feb 2015 18:58:13 +0000
> 
> kill-emacs contains the following code (
> http://git.savannah.gnu.org/cgit/emacs.git/tree/src/emacs.c#n1899):
> 
> if (feof (stdin))
>   arg = Qt;
> 
> According to git blame this was introduced in commit f927c5aed, the first
> revision.

Yes, so this code was there "forever".

> I suspect this code is responsible for the following somewhat surprising
> behavior:
> 
> $ emacs -Q -batch -eval '(kill-emacs 37)' < /dev/null ; echo $?
> 37
> 
> $ emacs -Q -batch -eval '(progn (read) (kill-emacs 37))' < /dev/null ; echo
> $?
> Lisp expression: Error reading from stdin
> 0
> 
> So Emacs silently succeeds if it hit EOF of stdin, no matter what the exit
> code passed to kill-emacs was!

I think in the second case kill-emacs isn't called at all, because
'read' signals an error.  Then Emacs exits because this is -batch
invocation.

> This can be a problem for batch jobs that use kill-emacs, e.g.
> ert-run-tests-batch-and-exit.

If you have a real-life use case where this produces problems, I
suggest to report it with report-emacs-bug.

> Is this working as intended?

I think so, yes.

> If so, what's the reason?

Reason for what? for that 'if' clause you mentioned?  It's to avoid
stuffing unread input when there's no one who will read it in the
first place.

> Is there a way to work around this behavior?

Why would you want to?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]