* Q: Killing a process and all child processes
@ 1997-09-25 4:00 hoevermann
1997-09-29 4:00 ` randolpho
0 siblings, 1 reply; 2+ messages in thread
From: hoevermann @ 1997-09-25 4:00 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Q: Killing a process and all child processes
1997-09-25 4:00 Q: Killing a process and all child processes hoevermann
@ 1997-09-29 4:00 ` randolpho
0 siblings, 0 replies; 2+ messages in thread
From: randolpho @ 1997-09-29 4:00 UTC (permalink / raw)
To: hoevermann
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1997-09-29 4:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-09-25 4:00 Q: Killing a process and all child processes hoevermann
1997-09-29 4:00 ` randolpho
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox