diff options
author | 2002-05-22 17:19:15 +0000 | |
---|---|---|
committer | 2002-05-22 17:19:15 +0000 | |
commit | 158e5da0e72e4a1197a887c004d36e6e847cd3fa (patch) | |
tree | 96ac85038b9b23a6007b21377f3c7b7788c7f3ab | |
parent | o avoid stdio in acquire_daemonlock() so we don't leak FILE * memory (diff) | |
download | wireguard-openbsd-158e5da0e72e4a1197a887c004d36e6e847cd3fa.tar.xz wireguard-openbsd-158e5da0e72e4a1197a887c004d36e6e847cd3fa.zip |
Remove pid file if sent SIGINT or SIGTERM before exiting.
-rw-r--r-- | usr.sbin/cron/cron.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/usr.sbin/cron/cron.c b/usr.sbin/cron/cron.c index 1ae01bf981d..a7703051157 100644 --- a/usr.sbin/cron/cron.c +++ b/usr.sbin/cron/cron.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cron.c,v 1.22 2002/05/21 20:57:32 millert Exp $ */ +/* $OpenBSD: cron.c,v 1.23 2002/05/22 17:19:15 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved */ @@ -21,7 +21,7 @@ */ #if !defined(lint) && !defined(LINT) -static char rcsid[] = "$OpenBSD: cron.c,v 1.22 2002/05/21 20:57:32 millert Exp $"; +static char rcsid[] = "$OpenBSD: cron.c,v 1.23 2002/05/22 17:19:15 millert Exp $"; #endif #define MAIN_PROGRAM @@ -39,6 +39,7 @@ static void usage(void), sighup_handler(int), sigchld_reaper(void), check_sigs(int), + quit(int), parse_args(int c, char *v[]); static volatile sig_atomic_t got_sighup, got_sigchld; @@ -86,6 +87,9 @@ main(int argc, char *argv[]) { sact.sa_handler = SIG_IGN; (void) sigaction(SIGPIPE, &sact, NULL); (void) sigaction(SIGUSR1, &sact, NULL); /* XXX */ + sact.sa_handler = quit; + (void) sigaction(SIGINT, &sact, NULL); + (void) sigaction(SIGTERM, &sact, NULL); acquire_daemonlock(0); set_cron_uid(); @@ -411,6 +415,16 @@ sigchld_handler(int x) { } static void +quit(int x) { + char pidfile[MAX_FNAME]; + + if (glue_strings(pidfile, sizeof pidfile, PIDDIR, PIDFILE, '/')) + (void) unlink(pidfile); + + _exit(0); +} + +static void sigchld_reaper() { WAIT_T waiter; PID_T pid; |