Subject: bug#17561: Emacs can forget processes

From: Jorgen Schaefer <[email-masked]>
Date: Thu, 29 May 2014 19:03:26 +0200

On Thu, 29 May 2014 08:26:31 -0700
Paul Eggert <[email-masked]> wrote:

> Andreas Schwab wrote:
> > Nothing in that sequence unblocks SIGCHLD.
> 
> Ouch; thanks, you're right, I misread that sequence.
> 
> So I'd like to see an strace of a session to see where Emacs first 
> blocked SIGCHLD, so that we can figure out why Emacs didn't soon
> unblock it.

Ok, let's see.

--- SIGCHLD (Child exited) @ 0 (0) ---

It works. A bit later:

rt_sigprocmask(SIG_BLOCK, [CHLD], [QUIT ALRM PROF], 8) = 0
rt_sigprocmask(SIG_SETMASK, [QUIT ALRM PROF], NULL, 8) = 0

That's fine, CHLD is not masked. A while later, then, this:

--- SIGIO (I/O possible) @ 0 (0) ---
rt_sigreturn(0x1d)                      = 11684722
ioctl(3, FIONREAD, [0])                 = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [QUIT ALRM CHLD PROF], 8) = 0
kill(4294962810, SIGKILL)               = 0
rt_sigprocmask(SIG_SETMASK, [QUIT ALRM CHLD PROF], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [QUIT ALRM CHLD PROF], 8) = 0
kill(4294962810, SIGHUP)                = 0
rt_sigprocmask(SIG_SETMASK, [QUIT ALRM CHLD PROF], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [QUIT ALRM CHLD PROF], 8) = 0
kill(4294942593, SIGKILL)               = 0
rt_sigprocmask(SIG_SETMASK, [QUIT ALRM CHLD PROF], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [QUIT ALRM CHLD PROF], 8) = 0
kill(4294942593, SIGHUP)                = 0
rt_sigprocmask(SIG_SETMASK, [QUIT ALRM CHLD PROF], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [WINCH IO], NULL, 8) = 0
write(3, "\33[K\33[13;12H", 11)         = 11
rt_sigprocmask(SIG_UNBLOCK, [WINCH IO], NULL, 8) = 0
--- SIGIO (I/O possible) @ 0 (0) ---
rt_sigreturn(0x1d)                      = 101
ioctl(3, FIONREAD, [0])                 = 0
rt_sigprocmask(SIG_BLOCK, [WINCH IO], NULL, 8) = 0
write(3, "\33[9;1H\33[?25l\33[46m(\33[39;49m\33[13;1"..., 48) = 48
write(3, "\33[34h\33[?25h\33[34l", 16)  = 16
rt_sigprocmask(SIG_UNBLOCK, [WINCH IO], NULL, 8) = 0
--- SIGIO (I/O possible) @ 0 (0) ---

If I read this right, this leaves CHLD blocked (SETMASK for CHLD, then
BLOCK WINCH IO, UNBLOCK WINCH IO, etc.)

Full trace attached. Uncompressed, that's 8.3M, mostly because of the
tight select/read loop.

What I did there was to start a process using my "test code" (temp
buffer cat), then start a few Python RPC processes (which cause some
noise), and then kill them all using the elpy-rpc-restart function I
posted before.

Regards,
Jorgen