diff options
author | Sunil Nimmagadda <sunil@cvs.openbsd.org> | 2015-12-08 17:28:04 +0000 |
---|---|---|
committer | Sunil Nimmagadda <sunil@cvs.openbsd.org> | 2015-12-08 17:28:04 +0000 |
commit | 78760051a152cf4a24dde92c4d73bd224b45062c (patch) | |
tree | 62f628318b81aee5ff7bdcaabb8fc6b17b0dff82 /usr.sbin | |
parent | 305af8697c47c9c6ea2fc3791274f28836b3bc63 (diff) |
Let smtpd shutdown gracefully with a zero exit code when the priv
process receives a SIGINT/SIGTERM.
Initial diff by nfnty <git@nfnty.se>
Ok gilles@ jung@ millert@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/smtpd/smtpd.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c index adfc4ec8866..4700f61a1a8 100644 --- a/usr.sbin/smtpd/smtpd.c +++ b/usr.sbin/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.258 2015/12/05 21:27:42 mmcc Exp $ */ +/* $OpenBSD: smtpd.c,v 1.259 2015/12/08 17:28:03 sunil Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -322,14 +322,15 @@ static void parent_sig_handler(int sig, short event, void *p) { struct child *child; - int die = 0, status, fail; + int die = 0, die_gracefully = 0, status, fail; pid_t pid; char *cause; switch (sig) { case SIGTERM: case SIGINT: - die = 1; + log_info("info: %s, shutting down", strsignal(sig)); + die_gracefully = 1; /* FALLTHROUGH */ case SIGCHLD: do { @@ -424,6 +425,8 @@ parent_sig_handler(int sig, short event, void *p) if (die) parent_shutdown(1); + else if (die_gracefully) + parent_shutdown(0); break; default: fatalx("smtpd: unexpected signal"); |