OSX: which type of Daemon/Background Process should I use? -


i have program want run on startup , wakeup sleep. however, found resource on number of different kinds of services of use me. need answer on kind of daemon/background service suits purposes best. here outline of details program:

1) launch automatically, in background (aka without user being aware of it) when computer either woken sleep, restarted, or started shutdown-state.

2) program operate separately each user. files created result of program's operation need separate each user.

i found resource @ https://developer.apple.com/library/mac/documentation/macosx/conceptual/bpsystemstartup/chapters/designingdaemons.html#//apple_ref/doc/uid/10000172i-sw4-bbcbhbfb unsure use: login item, xpc service, launch daemon, or launch agent.

2) program operate separately each user. files created result of program's operation need separate each user.

this suggests using launchagent, since per-user (and run user).

the page you'll want launchd.plist man page.

i'm not aware of launchd trigger matches request, unfortunately may mean need run keepalive option , monitor power changes.

you catch login (though not boot, since that's not "per user") @ point launch, that's easy. sleep , powerdown pretty managed through cocoa , nsworkspace observing notifications nsworkspacewillpoweroffnotification , nsworkspacewillsleepnotification. if cocoa high-level problem, can hook iokit power management events. see managing power in iokit fundamentals low-level introduction.

note there "kind of awake not really" state called darkwake, can confuse depending on needs. 2012 wwdc video on power management introduction issue.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -