Subject: bug#17561: Emacs can forget processes

From: Paul Eggert <[email-masked]>
Date: Thu, 29 May 2014 08:09:19 -0700

Jorgen Schaefer wrote:

> I can not currently build the emacs-24 branch (and haven't found a
> commit in it that I can on a quick try), see bug#17629.

That's an indication of a reasonably-serious problem with Emacs and your 
platform, which is worrisome and should get fixed.  I've responded at 
Bug#17629.

> Using trunk (git 40f5ec0 * alloc.c (Fgarbage_collect): Fix compilation
> with GC_MARK_STACK == GC_USE_GCPROS_AS_BEFORE.) now, built with your
> patch and this command:
>
> $ ./autogen.sh && ./configure --without-x && make clean && make
>
> When restarting Emacs, I had the bug happen again right away. Sadly
> without a running strace.

If the bug is easily reproducible, that's progress.  The patch does fix 
a bug (even if it's not your bug), so I've pushed it into the trunk. 
Can you get an strace -f of when Emacs stops getting SIGCHLD?  That's 
the crucial part.  That is, early on in all the straces I've seen, child 
processes die, Emacs gets a SIGCHLD, and then it calls waitpid (wait4) 
to reap them.  At some point this stops working, and Emacs no longer 
gets a SIGCHLD when a child terminates.  We need to find out what this 
point is, and what's causing it.

> 13:28:46 kill(4294962889, SIGKILL)      = 0 <0.002883>
> 13:28:46 --- SIGIO (I/O possible) @ 0 (0) ---
> 13:28:46 rt_sigreturn(0x1d)             = 0 <0.000021>
> 13:28:46 rt_sigprocmask(SIG_SETMASK, [QUIT ALRM CHLD PROF], NULL, 8) = 0 <0.000016>
> 13:28:46 ioctl(3, FIONREAD, [0])        = 0 <0.000018>
> 13:28:46 rt_sigprocmask(SIG_BLOCK, [CHLD], [QUIT ALRM CHLD PROF], 8) = 0 <0.000017>
> 13:28:46 kill(4294962889, SIGHUP)       = 0 <0.000017>

I'm surprised by the above trace.  The first kill(-4407,SIGKILL) 
succeeds, indicating that Emacs still has a subprocess.  But Emacs 
doesn't get a SIGCHLD, even after it unblocks SIGCHLD.  It would be 
helpful to see an 'strace -f' to see what's going on in the children here.