Re: recursively kill the childs of a process



In article <slrndsai3t.4t2.stephane.chazelas@xxxxxxxxxxxxxxx>,
Stephane CHAZELAS <this.address@xxxxxxxxxx> wrote:

> 2006-01-10, 17:03(-06), joe@xxxxxxxxxxxxxxx:
> > "Atropo" <lxvasquez@xxxxxxxxx> writes:
> >
> >> Posted before but no one answers.
> >> Here is the issue:
> >> there is a process that must be shutdown for maintenance purpose every
> >> morning at 5:00 am. usually it spawn several childs.., sometimes some
> >> of this childs don't die so the parent process either. When the
> >> aplication starts up again it raises a new parent process but in
> >> confict with the old one that have not died yet.. all i need is kill
> >> the childs of the old one process.
> >>
> >> $ ps -fea|grep "Process"|grep -v grep
> >>
> >> it gives me the two main process. like this
> >> pid ppid
> >> user 96218 1 0 06:15:05 - 0:20 MainProcess
> >> user 53214 1 0 Jan 10 - 1:15 MainProcess
> >>
> >> after this how can i search for every process who parent process id is
> >> 53214 to kill it ??
> >
> > Just send a signal to the process group, which is the parent process'
> > pid
>
> Well, you may see that you are killing more processes than you
> want if the process you want the children to be killed is not
> the leader of the process group.

If it's not a process group leader, then you won't kill any processes,
because the negative of its PID won't be a valid PGID. So you'll either
kill the processes you intend or you'll kill nothing.

--
Barry Margolin, barmar@xxxxxxxxxxxx
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
.



Relevant Pages

  • Re: recursively kill the childs of a process
    ... >> of this childs don't die so the parent process either. ... all i need is kill ... > Just send a signal to the process group, ...
    (comp.unix.shell)
  • Re: recursively kill the childs of a process
    ... >>> of this childs don't die so the parent process either. ... >> Just send a signal to the process group, ... if the OP wants grandchild processes spared while killing the ...
    (comp.unix.shell)
  • Re: NEWBIE: how to find and kill by Parent PID
    ... >> there is a process that must be shutdown for maintenance purpose every ... >> usually it spawn several childs.., ... >> don't die so the parent process either.. ... all i need is kill the childs of the old one ...
    (comp.unix.shell)
  • recursively kill the childs of a process
    ... there is a process that must be shutdown for maintenance purpose every ... of this childs don't die so the parent process either. ... all i need is kill ...
    (comp.unix.shell)
  • Re: recursively kill the childs of a process
    ... > of this childs don't die so the parent process either. ... all i need is kill ... Just send a signal to the process group, ...
    (comp.unix.shell)