sleep wake without runloop


Gerriet M. Denkmann
 

macOS 13.1

Is there a way to ascertain whether a process is sleeping or awake?

There is IORegisterForSystemPower which sends seep/wake notifications but needs a runloop.

Anything else?

Background: I want to modify chronyd, a LaunchDaemon, which being multi-platform does not have a runloop.
The problem: between NSWorkspaceWillSleepNotification and NSWorkspaceDidWakeNotification this (as any app) will be active from time to time (every few minutes it will be active for almost a minute), which messes up the internals of chronyd.


Gerriet.

Join cocoa@apple-dev.groups.io to automatically receive all group messages.