Hello,
I have been going through stevens advanced unix programming book and have recently written a webserver. When adding forks to service incoming requests in the child and continue listening for new clients on the parent I came to a problem. Stevens says either a return from main or an exit in the child will kill the process, either that or wait() on the parent for the child. When calling exit or return from the child the processes are not being deleted but put into zombie states. Is there something I'm doing wrong? My server is long so ill give the general gist of my program.
Code:
int main()
{
if(fork() == 0)
{
//handle client etc etc
return 0;
}
else
{
//parent
//block on accept.
}
}
So I guess my question: Is return/exit not the way to ensure a child process is completely killed and not just made into a zombie? If not how can I get rid of my process without blocking on wait()?
Thanks =D