fix preselection of instructions set
[openadk.git] / package / sash / src / shutdown.c
blob52d0530d85fb012b69f041e067c0b81ef61e4453
1 /* shutdown.c:
3 * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>,
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 */
11 #include "sash.h"
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <unistd.h>
16 #include <string.h>
17 #include <fcntl.h>
18 #include <sys/types.h>
20 #include <sys/stat.h>
21 #include <dirent.h>
22 #include <pwd.h>
23 #include <grp.h>
24 #include <time.h>
25 #include <signal.h>
26 #include <unistd.h>
27 #include <sys/reboot.h>
29 int
30 main(argc, argv)
31 int argc;
32 char **argv;
34 char *progname = argv[0];
36 if (argc > 2 && strcmp(argv[1], "-d") == 0) {
37 sleep(atoi(argv[2]));
38 argc -= 2;
40 if ((argc != 3) || (strcmp(argv[1], "-h") && strcmp(argv[1], "-r")) || strcmp(argv[2], "now")) {
41 printf("Usage: %s [-d delay] -h|-r now\n", progname);
42 exit(0);
45 kill(1, SIGTSTP);
46 sync();
47 signal(SIGTERM,SIG_IGN);
48 setpgrp();
49 kill(-1, SIGTERM);
50 sleep(1);
51 kill(-1, SIGHUP); /* Force PPPD's down, too */
52 sleep(1);
53 kill(-1, SIGKILL);
54 sync();
55 sleep(1);
57 if (strcmp(argv[1], "-h")==0) {
58 reboot(0xCDEF0123);
59 } else {
60 reboot(0x01234567);
63 exit(0); /* Shrug */