fix pr-2619, from cgd. really obscure bug in exec'ing reboot when single user.

This commit is contained in:
perry 1997-07-19 22:27:20 +00:00
parent 9aea42ec4e
commit 28753bf1c0
1 changed files with 14 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: reboot.c,v 1.12 1997/07/17 02:52:22 perry Exp $ */
/* $NetBSD: reboot.c,v 1.13 1997/07/19 22:27:20 perry Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)reboot.c 8.1 (Berkeley) 6/5/93";
#else
static char rcsid[] = "$NetBSD: reboot.c,v 1.12 1997/07/17 02:52:22 perry Exp $";
static char rcsid[] = "$NetBSD: reboot.c,v 1.13 1997/07/19 22:27:20 perry Exp $";
#endif
#endif /* not lint */
@ -155,8 +155,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