Subject: bug#15983: 24.3; Emacs Not Killing Child Process

From: Joan Karadimov <[email-masked]>
Date: Thu, 19 Dec 2013 17:44:37 +0200

> Emacs on Windows can only monitor and kill its immediate subprocesses,
> it cannot monitor, let alone kill, any of their descendant processes,> because it has no idea about them.  And the OS doesn't automatically> kill all the processes in the subprocess tree, and there's no way to> send a signal to them all, as on Posix platforms.  If killing the> immediate child process doesn't cause some of its children to exit or> abort, then those grandchildren will be left orphaned.
Windows NT does have the concept of parent processes, but an API call
wasn't exposed in win32 until XP. I wrote a small patch that uses that
and kills all child processes (as long as pid<0). I did some sanity
testing and it works.

There are a few things that this patch leaves unaddressed:- there is
no error handling
- there is no OS detection - this will get ugly on Windows 9x and
NT4/5.0- performance: 3 API calls are made for each descendant
process. This can be reduced to a total 3 calls (regardless of the
child process count)

I'll fix these (and any other issues) if this fix is of any interest.