* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
static char sccsid
[] = "@(#)reboot.c 5.2 (Berkeley) %G%";
openlog("reboot", 0, LOG_AUTH
);
if (!strcmp(*argv
, "-q"))
else if (!strcmp(*argv
, "-n"))
"usage: reboot [ -n ][ -q ]\n");
signal(SIGHUP
, SIG_IGN
); /* for remote connections */
if (kill(1, SIGTSTP
) == -1) {
fprintf(stderr
, "reboot: can't idle init\n");
if (!qflag
) for (i
= 1; ; i
++) {
if (kill(-1, SIGKILL
) == -1) {
fprintf(stderr
, "CAUTION: some process(es) wouldn't die\n");
if ((howto
& RB_NOSYNC
) == 0)
syslog(LOG_CRIT
, "halted for reboot");
if (!(howto
& RB_NOSYNC
)) {
/* RRRIIINNNGGG RRRIIINNNGGG */
signal(SIGALRM
, dingdong
);
#define SCPYN(a, b) strncpy(a, b, sizeof(a))
char wtmpf
[] = "/usr/adm/wtmp";
register f
= open(wtmpf
, 1);
SCPYN(wtmp
.ut_line
, "~");
SCPYN(wtmp
.ut_name
, "shutdown");
write(f
, (char *)&wtmp
, sizeof(wtmp
));