|
|
1.1 root 1: /*
2: * reboot.c - command to reboot the system
3: *
4: * "-p" option prompts and will sync before rebooting.
5: */
6:
7: #include <stdio.h>
8: #include <signal.h>
9: #include <sys/param.h>
10:
11: sigquiet(sig)
12: int sig;
13: {
14: signal(sig, sigquiet);
15: }
16:
17: main (argc, argv) int argc; char *argv[];
18: {
19: char buf[80];
20:
21: if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'p') {
22: /* Prompt before reboot. */
23: printf("Hit <Enter> and your system will reboot automatically... ");
24: fflush(stdout);
25: sync();
26: fgets(buf, sizeof buf, stdin);
27: }
28:
29: /*
30: * Trap alarm signals.
31: */
32: signal(SIGALRM, sigquiet);
33:
34: /*
35: * Wait at least 4 seconds for drives to turn off, etc.
36: */
37: alarm(5);
38: pause();
39:
40: /*
41: * Reboot the processor.
42: */
43: if (cohcall(COH_REBOOT) == -1)
44: perror(argv[0]);
45:
46: /*
47: * Should never reach here.
48: */
49: exit(1);
50: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.