Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basics for Killing Zombies Parents

Status
Not open for further replies.

tarn

Technical User
Aug 19, 2001
534
GB
I see the cry for help regarding the Perl Scripts creating zombies, has disappeared now, shame, as I was hoping for a $250 donation to Tek-Tips for this:

Anyway I've been playing and have come up with the following, yes it needs some tidying but that’s up to anyone that feels the urge.

#!/bin/bash -x
# remove -x to turn off debugging,
# ZOMBIE (parent) KILLER Script (Laurie 24/07/03)
#set array
declare -a tictoc

#populate array with zombies parent pid
tictoc=`ps -el| grep "Z" | grep -v grep|grep -v PPID| awk '{print $5}'`

#more debugging
echo "All these parents have zombies ${tictoc[*]}"
#loop to kill parent pid's
for T in ${tictoc[*]}
do
kill $T
done

To test ---------------------------
I found this code, just call it z2.c and compile it as commented in code, this will produce a script that generates a zombie. run in multi terms will generate multi zombies
------------------------------------------------------
/* Use the following to compile: cc z2.c -lm -o z2 */
/*Code for the C program that generates a Zombie */

#include

int main()
{

if (fork()==0) { //spawn a new process
printf("Child sleeps\n");
sleep(5);
printf("Child exists\n");
exit(0);
}

else {
sleep(90); //parent sleeps for 90 seconds
exit(0);
}

}
-------------------------------------------------
Enjoy;
Good Luck
Laurie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top