+ /* --- Set various things up --- */
+
+ if (chdir(dir)) {
+ 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, "couldn't open `%s' for writing: %s",
+ pidfile, strerror(errno));
+ }
+ signal(SIGINT, sigdie);
+ signal(SIGQUIT, sigdie);
+ signal(SIGTERM, sigdie);
+ atexit(cleanup);
+