X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: Jim Seymour Subject: How do I kill a grandchild process from shell program? Date: Mon, 23 Oct 2006 17:10:08 -0700 Lines: 44 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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. Questions: 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... -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Note 1) Here's an example "ps" output and the associated "kill" command: $ ps 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 -- Jim Seymour -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/