aboutsummaryrefslogtreecommitdiff
path: root/bin/shalt.c
blob: 9dc002837c0346d9120d53b1e5b972f59f6c4ec7 (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 <sys/reboot.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.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;
}