diff --git a/ggatessh/ggatessh.c b/ggatessh/ggatessh.c index 2b1f27c..f8a2337 100644 --- a/ggatessh/ggatessh.c +++ b/ggatessh/ggatessh.c @@ -685,6 +685,27 @@ procreq: pthread_exit(NULL); } +static void +ggatessh_makepidfile(void) +{ + pid_t otherpid; + + if (!g_gate_verbose) { + if (ggatessh_pidfile == NULL) { + asprintf(&ggatessh_pidfile, _PATH_VARRUN "/ggatessh.ggate%d.pid", unit); + err(EXIT_FAILURE, "Cannot allocate memory for pidfile"); + } + pfh = pidfile_open(ggatessh_pidfile, 0600, &otherpid); + if (pfh == NULL) { + if (errno == EEXIST) { + errx(EXIT_FAILURE, "Daemon already running, pid: %jd.", + (intmax_t)otherpid); + } + err(EXIT_FAILURE, "Cannot open/create pidfile"); + } + } +} + static void mydaemon(void) { @@ -879,30 +900,9 @@ handle_params(int argc, char *argv[]) imgpath = argv[1]; } -void -ggatessh_makepidfile(void) -{ - - if (!g_gate_verbose) { - if (ggatessh_pidfile == NULL) { - asprintf(&ggatessh_pidfile, _PATH_VARRUN "/ggatessh.ggate%d.pid", unit); - err(EXIT_FAILURE, "Cannot allocate memory for pidfile"); - } - pfh = pidfile_open(ggatessh_pidfile, 0600, &otherpid); - if (pfh == NULL) { - if (errno == EEXIST) { - errx(EXIT_FAILURE, "Daemon already running, pid: %jd.", - (intmax_t)otherpid); - } - err(EXIT_FAILURE, "Cannot open/create pidfile"); - } - } -} - int main(int argc, char *argv[]) { - pid_t otherpid; int rc; if (argc < 2)