I have to kill/clean a zombie process in linux C. All I know is the PID of the zombie.
I'm creating a few zombie processes in a loop:
int i = 0;
for (i; i<5; i++)
{
system("(: & exec sleep 30) &"); // create zombie for 30 sec
}
I can get their PID number using:
system("ps aux | awk '{ print $8 " " $2 }' | grep -w Z");
But how to kill/clean them using just the PID? I'm saving the PID in a variable and standard signal:
kill(PID,9)
Doesn't even work, because the process is dead already. Any other way to achieve it? Please don't ask me why the hell I'm creating zombies to kill them later. It's not the case.