I'm reading Nginx Open Source and I wonder why would someone kill the parent process and let child process handle the rest of the program? Why not just let parent process handle it? Your help is very much appreciated.
I use Eclipse CDT to debug the program and this causes my debug come to a dead end since it continues debugging the parent process, not the child process (which actually handle the rest of program).
Here is a snippet of the code:
ngx_int_t
ngx_daemon(ngx_log_t *log)
{
int fd;
switch (fork()) {
case -1:
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "fork() failed");
return NGX_ERROR;
case 0:
break;
default:
exit(0);
}
/* Do stuff*/
}
EDIT: I understand that procedure is for deamonizing a program but I'm still wondering why should we do that in the beginning?