By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,609 Members | 1,161 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,609 IT Pros & Developers. It's quick & easy.

zombie to exist after the termination of main program..

P: 1
main()
{
pid_t child;
child=fork();

if(child > 0)

{sleep(60);
}

else
{exit(0);
}

}

the above code will create zombie process,which will be adopted by init as soon as parent process will dies.Can any one gimme a code or an alogrithm such that this zombie process should exists even after the termintaion of the main program....
Feb 22 '08 #1
Share this Question
Share on Google+
2 Replies

P: 90
main()
{
pid_t child;
child=fork();

if(child > 0)

{sleep(60);
}

else
{exit(0);
}

}

the above code will create zombie process,which will be adopted by init as soon as parent process will dies.Can any one gimme a code or an alogrithm such that this zombie process should exists even after the termintaion of the main program....
Hello,
You could avoid a process to get into Zombie state.but once it been to zombie you can't do anything , offcource if you know process id , it is possibe to kill.
In kernel mode it is possible to do something.
-Arul
Feb 24 '08 #2

ashitpro
Expert 100+
P: 542
main()
{
pid_t child;
child=fork();

if(child > 0)

{sleep(60);
}

else
{exit(0);
}

}

the above code will create zombie process,which will be adopted by init as soon as parent process will dies.Can any one gimme a code or an alogrithm such that this zombie process should exists even after the termintaion of the main program....
parent process won't die until all child finishes.
consider above process is "a.out", when you run this code.
and give the following command to view the process hierarchy.
"ps -eLF | grep a.out"
It will show you two "a.out" processes as running, out of which one will be defunct this is the child process. And other one is parent.
For 60 seconds this defunct will exist.

If you want this zombie process to exist, use non terminating loop in child code
Feb 25 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.