I was reading up about zombie process and I did this piece of code to create one.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
pid_t pid;
pid = fork();
/* parent */
if(pid)
{
sleep(60);
}
/* child */
else
{
printf("I'm the child\n");
exit(0);
}
}
I executed this and on another terminal I was watching the ps output. I could see that for those 60 seconds, the above executable was a zombie, as in, I was getting a.out<defunct>. All good!
But my question is, after 60 seconds,the executable is no longer a zombie process. So who moves it out of the process table, the parent itself or 'init' ?(Note : my parent process is not using 'wait')
Please advise.
Thanks
Bookmarks