Subject: Re: bug#17561: Emacs can forget processes

From: Jorgen Schaefer <[email-masked]>
Date: Fri, 30 May 2014 22:41:56 +0200

On Thu, 29 May 2014 23:07:06 -0700
Paul Eggert <[email-masked]> wrote:

> Andreas Schwab wrote:
> > quit_throw_to_read_char doesn't restore the signal mask.
> 
> Thanks for the diagnosis.  I installed trunk bzr 117201 to try to fix 
> this problem.  I don't see how this would explain the bug in
> emacs-24, though, as in emacs-24 the signal handler invokes
> pthread_sigmask (SIG_SETMASK, &empty_mask, 0) before calling
> quit_throw_to_read_char, and the pthread_sigmask call should restore
> the signal mask.

I haven't been able to reproduce the bug since I am running the
patched version. Does not say it's gone, but it's a good indication.

It is entirely possible that the hangs I have witnessed in the past
were caused by some other problem. As I said initially, it's only been
the last few days that I actually had the luck to track down the
behavior in the first place (being at work is a bad time to try and
find weird behavior of your editor, sadly :-)).

So I would assume that this bug is fixed, and if I come across weird
behavior again, I'll create a new report or re-open this one. Thank you
for the excellent debugging!

Possibly related, while trying to reproduce the bug, I have noticed
some other strange behavior. I managed to reduce it to the following
reproduction code:

(with-temp-buffer
  (let ((proc (start-process "test" (current-buffer) "bash" "-c"
                             "echo foo ; sleep 5")))
    (set-process-query-on-exit-flag proc nil)
    (accept-process-output nil 2)))

This hangs my normal Emacs for 2 seconds. A newly-started Emacs returns
immediately. I *suspect* that this is a timing issue, and strace
*seems* to concur - Emacs reads the "foo" from the subprocess before
running accept-process-output, and then just hangs for the two second
timeout, instead of noticing that there already was some output. Should
I create a new bug report for this?

Regards,
Jorgen