xref: /freebsd/usr.sbin/zzz/zzz.c (revision aba599a6cc550bf209b42a81a3cdb3f6e94d0613)
1 /*
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2026 The FreeBSD Foundation
5  *
6  * This software was developed by Aymeric Wibo <obiwac@freebsd.org>
7  * under sponsorship from the FreeBSD Foundation.
8  */
9 
10 #include <sys/power.h>
11 
12 #include <err.h>
13 #include <errno.h>
14 #include <fcntl.h>
15 #include <paths.h>
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <sysexits.h>
20 
21 static void
usage(void)22 usage(void)
23 {
24 	(void)fprintf(stderr, "usage: zzz\n");
25 	exit(1);
26 }
27 
28 int
main(int argc,char * argv[])29 main(int argc, char *argv[])
30 {
31 	int powerfd;
32 	enum power_transition trans;
33 
34 	(void)argv;
35 	if (argc > 1)
36 		usage();
37 
38 	powerfd = open(_PATH_DEVPOWER, O_RDWR);
39 	if (powerfd < 0)
40 		err(EX_OSFILE, "could not open power device");
41 
42 	trans = POWER_TRANSITION_SUSPEND;
43 	if (ioctl(powerfd, PIOTRANSITION, &trans) != 0)
44 		err(EX_IOERR, "could not request suspend transition");
45 
46 	return (EXIT_SUCCESS);
47 }
48