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
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