From: randolpho@usa.net
To: hoevermann@dialup.nacamar.de
Subject: Re: Q: Killing a process and all child processes
Date: 1997/09/29 [thread overview]
Message-ID: <875315407.3717@dejanews.com> (raw)
In-Reply-To: 60cra5$qhg$1@news.nacamar.de
In article <60cra5$qhg$1@news.nacamar.de>,
hoevermann@dialup.nacamar.de wrote:
>
> Hello,
>
> As I'm not a UNIX expert, I've got a prolblem with killing a process.
> This process creates several child processes and starts processes over
> a 'system'-call in a C-program. Now I have to kill this process and
> all child processes, but if I'm killing the parent, the children are
> still alive! When I begin killing the children, the parent always
> spawns new children as long as I'm killing the previously existing
> ones, and I never come to an end.
> Can anybody help me?
>
> Thank you in advance
> Markus
Use the command kill with the TERM signal. For example:
To kill process 12345 and all children processes use
kill -TERM 12345 or kill -15 12345
(The signals are listed in the file /usr/include/signal.h)
You can also use the script below :
!/bin/ksh
#killall - To invoke type killall <pid>
#If action is OK uncoment the kill commnands
#Caution if it is running as root.
my_ppid=$1
#Obtain children processes
ps axo ppid,pid | awk '{
if ($1 == "'$my_ppid'")
printf("%s\n",$2)
}' | while read child_pid
do
echo "kill -9 $child_pid" # Display action
#kill -9 $child_pid # Kill child process
done
echo "kill -9 $my_ppid" # Display action
#kill -9 $my_ppid # Kill parent process
Hope this helps.
Best Regards 8-)
Randolpho
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
prev parent reply other threads:[~1997-09-29 4:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-09-25 4:00 Q: Killing a process and all child processes hoevermann
1997-09-29 4:00 ` randolpho [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox