aboutsummaryrefslogtreecommitdiff
path: root/bin/shalt.c
blob: e47e7df4baca8f29bf5b5b55eaaed0beea0ff4a6 (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
36
37
/* shalt -- simple halt utility */
#define _XOPEN_SOURCE 500

#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;
}