daemon() has to be called prior to file descriptor setups

(otherwise file descriptors could be closed mistakenly)

Obtained from:	KAME
MFC after:	1 week
This commit is contained in:
Hajimu UMEMOTO 2003-08-14 19:05:24 +00:00
parent 455e535da1
commit 145b960169
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=118920

View File

@ -228,11 +228,11 @@ main(argc, argv)
fprintf(stderr, "fatal: inet_pton failed\n");
exit(1);
}
sock_open();
if (!fflag)
daemon(1, 0);
sock_open();
/* record the current PID */
pid = getpid();
if ((pidfp = fopen(pidfilename, "w")) == NULL) {