--- gvpe/src/util.C 2003/10/16 02:28:36 1.10 +++ gvpe/src/util.C 2004/06/11 15:56:34 1.15 @@ -1,5 +1,6 @@ /* util.C -- process management and other utility functions + Copyright (C) 2003-2004 Marc Lehmann Some of these are taken from tinc, see the AUTHORS file. @@ -21,6 +22,7 @@ #include "config.h" #include +#include #include #include @@ -46,16 +48,16 @@ { int pid; - pid = check_pid (pidfilename); + pid = check_pid (conf.pidfilename); if (pid) { - fprintf (stderr, _("A vped is already running with pid %d.\n"), pid); + fprintf (stderr, _("A gvpe daemon is already running with pid %d.\n"), pid); return 1; } /* if it's locked, write-protected, or whatever */ - if (!write_pid (pidfilename)) + if (!write_pid (conf.pidfilename)) return 1; return 0; @@ -66,11 +68,11 @@ { int pid; - pid = read_pid (pidfilename); + pid = read_pid (conf.pidfilename); if (!pid) { - fprintf (stderr, _("No other vped is running.\n")); + fprintf (stderr, _("No other gvpe daemon is running.\n")); return 1; } @@ -79,10 +81,10 @@ /* ESRCH is returned when no process with that pid is found */ if (kill (pid, signal) && errno == ESRCH) { - fprintf (stderr, _("The vped is no longer running. ")); + fprintf (stderr, _("The gvpe daemon is no longer running. ")); fprintf (stderr, _("Removing stale lock file.\n")); - remove_pid (pidfilename); + remove_pid (conf.pidfilename); } return 0; @@ -112,7 +114,7 @@ /* Now UPDATE the pid in the pidfile, because we changed it... */ - if (!write_pid (pidfilename)) + if (!write_pid (conf.pidfilename)) return -1; log_to (LOGTO_SYSLOG); @@ -120,21 +122,11 @@ else log_to (LOGTO_SYSLOG | LOGTO_STDERR); - slog (L_INFO, _("vped %s (%s %s) starting"), VERSION, __DATE__, __TIME__); + slog (L_INFO, _("gvpe daemon %s (%s %s) starting"), VERSION, __DATE__, __TIME__); return 0; } -void -make_names (void) -{ - if (!pidfilename) - pidfilename = LOCALSTATEDIR "/run/vped.pid"; - - if (!confbase) - asprintf (&confbase, "%s/vpe", CONFDIR); -} - void run_script (const run_script_cb &cb, bool wait) { int pid; @@ -144,7 +136,7 @@ char *filename; asprintf (&filename, "%s/%s", confbase, cb()); execl (filename, filename, (char *) 0); - exit (255); + exit (126); } else if (pid > 0) {