#define f_noinput 64u
#define f_warn 128u
#define f_uclose 256u
+#define f_losing 512u
/*----- Main code ---------------------------------------------------------*/
if (!p) {
if (f & f_command)
die(EXIT_FAILURE, "server dropped the connection");
+ f &= ~f_losing;
exit(0);
}
q = str_getword(&p);
die(EXIT_FAILURE, "couldn't set `%s' as current directory: %s",
dir, strerror(errno));
}
- if (logname)
- logfile(logname);
if (!pidfile && (f & f_daemon) && ((f & f_syslog) || logname))
pidfile = "tripectl.pid";
if (pidfile && (pidfp = fopen(pidfile, "w")) == 0) {
die(EXIT_FAILURE, "fork failed: %s", strerror(errno));
if (!kid) {
close(pfd[0]); close(efd[0]);
+ sigprocmask(SIG_SETMASK, &oldmask, 0);
md[0].cur = pfd[1]; md[0].want = STDIN_FILENO;
md[1].cur = pfd[1]; md[1].want = STDOUT_FILENO;
md[2].cur = efd[1]; md[2].want = STDERR_FILENO;
mdup(md, 3);
- if (logfp) fclose(logfp);
if (pidfp) fclose(pidfp);
closelog();
if (f & f_daemon) detachtty();
}
}
+ f |= f_losing; /* pessimism */
u_setugid(u, g);
+ if (logname)
+ logfile(logname);
if (f & f_daemon) {
if (daemonize())
die(EXIT_FAILURE, "error becoming daemon: %s", strerror(errno));