Created
November 8, 2014 04:19
-
-
Save mike-burns/b0241188bd6f1d571f8b to your computer and use it in GitHub Desktop.
Suspend your machine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Does not work if apmd(8) is running. */ | |
/* Requires read-write access to /dev/apmctl. */ | |
#include <sys/types.h> | |
#include <sys/event.h> | |
#include <sys/time.h> | |
#include <sys/ioctl.h> | |
#include <machine/apmvar.h> | |
#include <fcntl.h> | |
#include <stdio.h> | |
#include <err.h> | |
#define _PATH_APM_CTLDEV "/dev/apmctl" | |
int | |
main(int argc, char *argv[]) | |
{ | |
int fd, ret; | |
if ((fd = open(_PATH_APM_CTLDEV, O_RDWR)) == -1) | |
err(1, "open"); | |
if ((ret = ioctl(fd, APM_IOC_SUSPEND, NULL)) == -1) | |
err(1, "ioctl"); | |
printf("ioctl: %i\n", ret); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment