X-Spam-Check-By: sourceware.org
To: cygwin@cygwin.com
From: Matthew Woehlke <mwoehlke@tibco.com>
Subject:  Re: How do I kill a grandchild process from shell program?
Date:  Tue, 24 Oct 2006 14:56:17 -0500
Lines: 26
Message-ID: <ehlr51$nh$4@sea.gmane.org>
References:  <ehjll0$4f7$1@sea.gmane.org>
Mime-Version:  1.0
Content-Type:  text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding:  7bit
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20060909 Thunderbird/1.5.0.7 Mnenhy/0.7.4.0
In-Reply-To: <ehjll0$4f7$1@sea.gmane.org>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

Jim Seymour wrote:
> 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 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?

'kill -SIGHUP <process>'? Or if the child is a bash script, you might be 
able to re-write it to trap a signal (e.g. SIGUSR1) that instructs the 
child to kill /its/ child (the assumption being that the child knows its 
own child's PID).

-- 
Matthew
Only Joe suffers from schizophrenia. The rest of us enjoy it.


--
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/

