Subject: Re: bug#13475: 24.2.91; accept-process-output hangs emacs on killed sub-process

From: Lars Ingebrigtsen <[email-masked]>
Date: Thu, 03 Oct 2019 19:24:54 +0200

Vitalie Spinu <[email-masked]> writes:

> Accept-process-output, when run with WAIT argument, hangs emacs when the
> underlying sub-process was killed. When WAIT is nil this problem does
> not occur.
>
> Start M-x shell and execute:
>
>    (let ((proc (get-process "shell")))
>      (process-send-string proc "sleep 60\n")
>      (while (not (accept-process-output proc .01))))
>
> This puts emacs in a loop as expected. Now kill the bash process from
> outside emacs and you will see that emacs is still hanged.
>
> This problem does not occur when WAIT argument is nil. For example on
> the execution of the following code, emacs successfully exits the waiting
> loop after the bash process has been killed:
>
>    (let ((proc (get-process "shell")))
>      (accept-process-output proc))

(I'm going through old Emacs bug reports that unfortunately got no
response at the time.)

I'm don't think this is a bug -- as you say, if PROC is dead, then we
just heed the timeout, so in a loop like this, you should check whether
PROC is alive before calling `accept-process-output'.

So I'm closing this bug report.  I somebody things that Emacs should be
changed to make accept-process-output to return immediately (with a
non-nil return value?) if PROC is dead, please reopen.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no