Properly detach at startup. We could be passing revoked fd's to

child processes or starting children with no fd 0 (stdin) at all etc.
This is currently breaking on hub.freebsd.org.
This commit is contained in:
Peter Wemm 2001-03-07 10:38:46 +00:00
parent 06a9cc5bf7
commit 1db78faf47
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=73955

View File

@ -100,19 +100,9 @@ main(argc, argv)
# endif
(void) fprintf(stderr, "[%d] cron started\n", getpid());
} else {
switch (fork()) {
case -1:
log_it("CRON",getpid(),"DEATH","can't fork");
if (daemon(1, 0) == -1) {
log_it("CRON",getpid(),"DEATH","can't become daemon");
exit(0);
break;
case 0:
/* child process */
log_it("CRON",getpid(),"STARTUP","fork ok");
(void) setsid();
break;
default:
/* parent process should just die */
_exit(0);
}
}