static char *sccsid
= "@(#)halt.c 4.9 (Berkeley) %G%";
#define SHUTDOWNLOG "/usr/adm/shutdownlog"
char *ttyn
= (char *)ttyname(2);
if (!strcmp(*argv
, "-n"))
else if (!strcmp(*argv
, "-y"))
else if (!strcmp(*argv
, "-q"))
fprintf(stderr
, "usage: halt [ -n ]\n");
if (ttyn
&& *(ttyn
+strlen("/dev/tty")) == 'd') {
fprintf(stderr
, "halt: dangerous on a dialup; use ``halt -y'' if you are really sure\n");
signal(SIGHUP
, SIG_IGN
); /* for network 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)
if ((howto
& RB_NOSYNC
)==0) {
/* 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
));
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
struct tm
*tm
, *localtime();
fp
= fopen(SHUTDOWNLOG
, "a");
fprintf(fp
, "%02d:%02d %s %s %2d, %4d. Halted.\n", tm
->tm_hour
,
tm
->tm_min
, days
[tm
->tm_wday
], months
[tm
->tm_mon
],
tm
->tm_mday
, tm
->tm_year
+ 1900);