Browse Source

check return code of chdir and send SIGTERM to the childs when we shutdown

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@827 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.8
Jan Kneschke 16 years ago
parent
commit
319326b5af
  1. 11
      src/server.c

11
src/server.c

@ -96,15 +96,15 @@ static void daemonize(void) {
#ifdef SIGTSTP
signal(SIGTSTP, SIG_IGN);
#endif
if (fork() != 0) exit(0);
if (0 != fork()) exit(0);
if (setsid() == -1) exit(0);
if (-1 == setsid()) exit(0);
signal(SIGHUP, SIG_IGN);
if (fork() != 0) exit(0);
if (0 != fork()) exit(0);
chdir("/");
if (0 != chdir("/")) exit(0);
umask(0);
}
@ -829,6 +829,9 @@ int main (int argc, char **argv) {
num_childs++;
}
}
if (srv_shutdown) {
kill(0, SIGTERM);
}
if (!child) return 0;
}
#endif

Loading…
Cancel
Save