/*
- * $Id: main.cc,v 1.316 2000/07/13 06:13:42 wessels Exp $
+ * $Id: main.cc,v 1.317 2000/07/16 01:11:49 hno Exp $
*
* DEBUG: section 1 Startup and Main Loop
* AUTHOR: Harvest Derived
#endif
pid_t pid;
int i;
+ int nullfd;
if (*(argv[0]) == '(')
return;
openlog(appname, LOG_PID | LOG_NDELAY | LOG_CONS, LOG_LOCAL4);
close(i);
}
#endif
- for (i = 0; i < Squid_MaxFD; i++)
+ /* Connect stdio to /dev/null in daemon mode */
+ nullfd = open("/dev/null", O_RDWR);
+ dup2(nullfd, 0);
+ if (opt_debug_stderr < 0) {
+ dup2(nullfd, 1);
+ dup2(nullfd, 2);
+ }
+ /* Close all else */
+ for (i = 3; i < Squid_MaxFD; i++)
close(i);
for (;;) {
mainStartScript(argv[0]);