summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>1996-07-22 09:20:59 +0000
committerderaadt <deraadt@openbsd.org>1996-07-22 09:20:59 +0000
commit1342255217c6b7c248c49ce63d895f34396adb1b (patch)
tree9151b1ce811412d51a775596728c0b0e72b498cb
parentmake COPTS work in bsd.lib.mk too (diff)
downloadwireguard-openbsd-1342255217c6b7c248c49ce63d895f34396adb1b.tar.xz
wireguard-openbsd-1342255217c6b7c248c49ce63d895f34396adb1b.zip
kill (-1, SIGTERM) may find no other processes; netbsd pr#2619, cgd
-rw-r--r--sbin/reboot/reboot.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c
index aae79646b4c..caf185528f1 100644
--- a/sbin/reboot/reboot.c
+++ b/sbin/reboot/reboot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: reboot.c,v 1.3 1996/07/11 23:29:09 weingart Exp $ */
+/* $OpenBSD: reboot.c,v 1.4 1996/07/22 09:20:59 deraadt Exp $ */
/* $NetBSD: reboot.c,v 1.8 1995/10/05 05:36:22 mycroft Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)reboot.c 8.1 (Berkeley) 6/5/93";
#else
-static char rcsid[] = "$OpenBSD: reboot.c,v 1.3 1996/07/11 23:29:09 weingart Exp $";
+static char rcsid[] = "$OpenBSD: reboot.c,v 1.4 1996/07/22 09:20:59 deraadt Exp $";
#endif
#endif /* not lint */
@@ -148,8 +148,18 @@ main(argc, argv)
(void)signal(SIGHUP, SIG_IGN);
/* Send a SIGTERM first, a chance to save the buffers. */
- if (kill(-1, SIGTERM) == -1)
- err("SIGTERM processes: %s", strerror(errno));
+ if (kill(-1, SIGTERM) == -1) {
+ /*
+ * If ESRCH, everything's OK: we're the only non-system
+ * process! That can happen e.g. via 'exec reboot' in
+ * single-user mode.
+ */
+ if (errno != ESRCH) {
+ (void)fprintf(stderr, "%s: SIGTERM processes: %s",
+ dohalt ? "halt" : "reboot", strerror(errno));
+ goto restart;
+ }
+ }
/*
* After the processes receive the signal, start the rest of the