* Copyright (c) 1980, 1986 The Regents of the University of California.
* %sccs.include.redist.c%
"@(#) Copyright (c) 1980, 1986 The Regents of the University of California.\n\
static char sccsid
[] = "@(#)halt.c 5.10 (Berkeley) %G%";
int ch
, howto
, needlog
= 1;
char *user
, *ttyn
, *getlogin(), *ttyname();
while ((ch
= getopt(argc
, argv
, "lnqy")) != EOF
)
case 'l': /* undocumented; for shutdown(8) */
fprintf(stderr
, "usage: halt [-nqy]\n");
if (ttyn
&& ttyn
[sizeof(_PATH_TTY
) - 1] == 'd') {
fprintf(stderr
, "halt: dangerous on a dialup; use ``halt -y'' if you are really sure\n");
openlog("halt", 0, LOG_AUTH
);
if ((user
= getlogin()) == NULL
)
if ((pw
= getpwuid(getuid())))
syslog(LOG_CRIT
, "halted by %s", user
);
signal(SIGHUP
, SIG_IGN
); /* for network connections */
if (kill(1, SIGTSTP
) == -1) {
fprintf(stderr
, "halt: 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", "");
/* RRRIIINNNGGG RRRIIINNNGGG */
signal(SIGALRM
, dingdong
);