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:
parent
06a9cc5bf7
commit
1db78faf47
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=73955
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user