2

I'm trying to catch shutdown on osx. on Linux, I used runlevels to detect it, does mac have something like that? I cannot use events from cocoa because my app runs as daemon, and it wont send NSWorkspaceWillPowerOffNotification.

Zhani Baramidze
  • 1,407
  • 1
  • 13
  • 32
  • 1
    Have a look at my answer here... http://stackoverflow.com/questions/24200924/run-a-script-only-at-shutdown-not-log-off-or-restart-on-mac-os-x/24202568#24202568 It should be possible to add in a notification to your daemon within the wrapper I suggest. – Mark Setchell Dec 05 '14 at 13:15
  • thanks but I think it's not what I'm looking for. I want to detect it from my application, which runs as daemon. – Zhani Baramidze Dec 05 '14 at 16:07
  • Can you not send a message to your daemon from the script, using a semaphore/socket/message queue? – Mark Setchell Dec 05 '14 at 16:20
  • yes, that's one solution, but I'm looking for detection mechanism from code, without any extra process, if it turns out to be impossible, then I'll use this way :) – Zhani Baramidze Dec 05 '14 at 16:33

0 Answers0