* Copyright (c) 1980, 1986 The Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
"@(#) Copyright (c) 1980, 1986 The Regents of the University of California.\n\
static char sccsid
[] = "@(#)reboot.c 5.7 (Berkeley) %G%";
struct passwd
*pw
, *getpwuid();
openlog("reboot", 0, LOG_AUTH
);
if (!strcmp(*argv
, "-q"))
else if (!strcmp(*argv
, "-n"))
else if (!strcmp(*argv
, "-l"))
"usage: reboot [ -n ][ -q ]\n");
if (user
== (char *)0 && (pw
= getpwuid(getuid())))
syslog(LOG_CRIT
, "rebooted by %s", user
);
signal(SIGHUP
, SIG_IGN
); /* for remote connections */
if (kill(1, SIGTSTP
) == -1) {
fprintf(stderr
, "reboot: can't idle init\n");
(void) kill(-1, SIGTERM
); /* one chance to catch it */
if (!qflag
) for (i
= 1; ; i
++) {
if (kill(-1, SIGKILL
) == -1) {
"CAUTION: some process(es) wouldn't die\n");
if (!qflag
&& (howto
& RB_NOSYNC
) == 0) {
logwtmp("~", "shutdown", "");
syscall(SYS_reboot
, howto
);
/* RRRIIINNNGGG RRRIIINNNGGG */
signal(SIGALRM
, dingdong
);