Skip to content

Instantly share code, notes, and snippets.

@atr000
Created December 18, 2010 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atr000/746301 to your computer and use it in GitHub Desktop.
Save atr000/746301 to your computer and use it in GitHub Desktop.
sleep
#include <IOKit/IOKitLib.h>
#include <IOKit/pwr_mgt/IOPMLib.h>
#include <IOKit/IOReturn.h>
#include <mach/mach_init.h> /* for bootstrap_port */
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
int main(int argc, char *argv[])
{
mach_port_t master;
io_connect_t pmcon;
if (IOMasterPort(bootstrap_port, &master) != kIOReturnSuccess) {
perror("IOMasterPort() failed");
exit(1);
}
pmcon = IOPMFindPowerManagement(master);
if (pmcon == 0) {
fprintf(stderr, "IOPMFindPowerManagement() failed!\n");
exit(1);
}
if (IOPMSleepSystem(pmcon) != kIOReturnSuccess) {
perror("IOPMSleepSystem() failed");
exit(1);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment