[BBLISA] To kill a process tree

Edward Ned Harvey bblisa3 at nedharvey.com
Thu Apr 2 17:59:46 EDT 2009


I may do something like this, if I have no better alternative ... But it would need to be more powerful than what you wrote below.  It would have to be recursive, because we don't know how many levels deep the tree will go.

I appreciate the effort, and it appears you're better with awk than I am.  ;-)  If I wrote this myself, I'd probably rely on python and a list of tuples.



________________________________________
From: bblisa-bounces at bblisa.org [bblisa-bounces at bblisa.org] On Behalf Of Chaos Golubitsky [chaos at glassonion.org]
Sent: Thursday, April 02, 2009 4:50 PM
To: bblisa at bblisa.org
Subject: Re: [BBLISA] To kill a process tree

On Thu, 02 Apr, 2009 at 16:43:47 -0400, Edward Ned Harvey wrote:

> I know if I simply "kill pid" then the process and all its children
> will die.  But I don't want to kill them.  I want to "kill -SIGTSTP pid"
> ... and this works as long as I name all the pids in the process tree.
> It does not cascade the signal to all the child processes if I only name
> the parent pid.
>
> Does anybody know a way to send a specific kill signal to a all the
> descendents of some specific pid?

Do you need a single command.  I might do something along the lines of:

  ps -e -o pid,ppid | awk '$2=<ppid #> {print $1}' | xargs kill -WHATEVER

Your mileage may vary by OS, but you get the idea --- list all commands
and their PPIDs, select only the PIDs matching the PPID you want, and
then pipe through xargs to do the kill.

Chaos

_______________________________________________
bblisa mailing list
bblisa at bblisa.org
http://www.bblisa.org/mailman/listinfo/bblisa



More information about the bblisa mailing list