This is the mail archive of the
mailing list for the Cygwin project.
How do I kill a grandchild process from shell program?
- From: Jim Seymour <nntp dot ff at thentao dot com>
- To: cygwin at cygwin dot com
- Date: Mon, 23 Oct 2006 17:10:08 -0700
- Subject: How do I kill a grandchild process from shell program?
I've been Googling all afternoon trying to figure out whether this is a
bug, a "feature", or a stupid user problem. If it's the latter, I
apologize in advance...
I'm using Cygwin v1.5.21-2 and bash v3.1.17(9) under Windows XP Pro.
I have two shell programs - one that launches the other in the
background. The background one runs a utility program that (under
normal circumstances) will shut down gracefully.
However, if things don't work fine, the background process sticks around
to plague me later.
I'd like to end my main script by killing the background process (if
it's still around), but I'm having a helluva time figuring out HOW.
I thought I'd hit the jackpot when I learned about the %?S jobspec, but
kill doesn't seem to respect it. It reports "no such job" (see Note 1)
I can use "kill $!" in the main script, but that only kills the
background bash process, leaving the utility program running.
1) Is "kill %?name" supposed to work in this environment?
2) Is there a simple way to kill a process along with its children?
Thanks for reading this far...
Here's an example "ps" output and the associated "kill" command:
PID PPID PGID WINPID TTY UID STIME COMMAND
2196 1 2196 2196 con 11024 16:10:01 /usr/bin/bash
724 2196 724 716 con 11024 17:00:39 /usr/bin/sh
3340 724 724 3048 con 11024 17:00:41 /usr/local/bin/ocdremote
3556 2196 3556 2192 con 11024 17:00:49 /usr/bin/ps
$ kill %?ocdremote
bash: kill: %?ocdremote: no such job
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html