blob: dd642860170ed7da902679bd66b8dc5059f53940 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
/* shalt -- simple halt utility */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/reboot.h>
static char *argv0;
#include "arg.h"
static void
usage(void)
{
fprintf(stderr, "usage: %s [-pr]\n", argv0);
exit(1);
}
int
main(int argc, char *argv[])
{
sync();
ARGBEGIN {
case 'p':
reboot(RB_POWER_OFF);
break;
case 'r':
reboot(RB_AUTOBOOT);
break;
default:
usage();
} ARGEND
if (argc != 2) usage();
return 0;
}
|