diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-07-22 09:21:00 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-07-22 09:21:00 +0000 |
commit | 5a9e962ff25b3c6260d6a5c8d0fa57a7198a1147 (patch) | |
tree | a820df5d5bc8e020152e7998647a39ec23c77984 /sbin | |
parent | 4b7ba00d980d59fc0af58c8efd1ad7fd52f7c718 (diff) |
kill (-1, SIGTERM) may find no other processes; netbsd pr#2619, cgd
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/reboot/reboot.c | 18 |
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 |