I am attempting to schedule my machine to go to sleep after 35 seconds. Here is the code I am using
This returns returnCode = -536870207 and doesn't put the machine to sleep. Seems to me like a buffer overflow... and I'm sure the issue with my computation of the CFDateRef... Any help would be great.
EDIT: I just determined that that returnCode is kIOReturnNotPrivileged
http://gemma.apple.com/documentation/Darwin/Reference/KernelIOKitFramework/IOReturn/index.html
EDIT2: In order to bypass the privilege nonsense... I ran from the terminal with a preceding sudo... works well
Code:
CFAbsoluteTime currentTime = CFAbsoluteTimeGetCurrent();
CFDateRef wakeFromSleepAt = CFDateCreate(NULL, currentTime + 35);
IOReturn returnCode = IOPMSchedulePowerEvent(wakeFromSleepAt, NULL, CFSTR(kIOPMAutoSleep));
This returns returnCode = -536870207 and doesn't put the machine to sleep. Seems to me like a buffer overflow... and I'm sure the issue with my computation of the CFDateRef... Any help would be great.
EDIT: I just determined that that returnCode is kIOReturnNotPrivileged
http://gemma.apple.com/documentation/Darwin/Reference/KernelIOKitFramework/IOReturn/index.html
EDIT2: In order to bypass the privilege nonsense... I ran from the terminal with a preceding sudo... works well