From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,6014516707498602 X-Google-Attributes: gidfee84,public From: randolpho@usa.net Subject: Re: Q: Killing a process and all child processes Date: 1997/09/29 Message-ID: <875315407.3717@dejanews.com>#1/1 X-Deja-AN: 276406156 References: <60cra5$qhg$1@news.nacamar.de> To: hoevermann@dialup.nacamar.de X-Http-User-Agent: Mozilla/2.0 (compatible; MSIE 3.01; Windows 95) X-Originating-IP-Addr: 200.241.215.13 (belenus.cvrd.com.br) Organization: Dynamis X-Authenticated-Sender: randolpho@usa.net X-Article-Creation-Date: Fri Sep 26 23:10:07 1997 GMT Newsgroups: comp.unix.osf.osf1 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 #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