Operating System - HP-UX
1819947 Members
3620 Online
109607 Solutions
New Discussion юеВ

How to kill Parent & Child Process.

 
Archana1
Frequent Advisor

How to kill Parent & Child Process.

Want to kill Parent Process and associated child processes.

with kill -9 only Parent process is killed and child process becoming orphan..
Please help..
5 REPLIES 5
Dennis Handly
Acclaimed Contributor

Re: How to kill Parent & Child Process.

How deep do you want to go, just one level?
Manix
Honored Contributor

Re: How to kill Parent & Child Process.

In case the child are orphan they maybe "zombies" & cant be killed

check with "ps -el|grep Z"

# ps -el|grep Z

# ps -ef|grep defunct

If we have defunct processes we may need to
reboot.


If any process terminates before its children do, init inherits those children. When they die, init calls one of the wait() functions to retrieve the child's termination status, and the child disappears from the process table.

Pleas read this

http://h30499.www3.hp.com/t5/System-Administration/Question-on-defunct-zombie-process-UX/m-p/4004591#M297832

HP-UX been always lovable - Mani Kalra
blackwater
Regular Advisor

Re: How to kill Parent & Child Process.

What about a simple script like this:

#!/bin/sh
# killh.sh -killing a process and its child processes
[ $# -eq 1 ] || return 0
UNIX95= ps -e -o ppid,pid | awk '{if ('"$1"'==$1) print $2}' | xargs -t -n 1 ./killh.sh
kill -9 $1
Dennis Handly
Acclaimed Contributor

Re: How to kill Parent & Child Process.

>blackwater: What about a simple script like this:

You need to be very careful about running a script like this. :-)
Add "echo" in front of that kill -9 until you are happy.

Also, you may want a normal kill before you try -9.
James R. Ferguson
Acclaimed Contributor

Re: How to kill Parent & Child Process.

HI:

Using a 'kill -9' doesn't give a process a chance to catch the signal and cleanup. That is, there is no way for the process to remove any temporary files or shared memory segments. It is for this reason, as Dennis hinted, that you should try a "kinder" 'kill' first, using a 'kill -9' only if the process won't die. Even with a 'kill -9' a process that is waiting on a kernel event (such as an I/O completion) will not die until the higher event is satisfied.

Regards!

...JRF...