Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How can my daemon detect that machine is restarted



Hi,

I need to find out if my daemon was launched after a restart or during the normal install. Basically I need to now if a machine was restarted.
I thought IORegisterForSystemPower would do this but I do not get the kIOMessageSystemWillRestart message.


Here is my code that registers for the notification.

gRootPort=IORegisterForSystemPower (0,&notify,SystemPowerChangedCallback,&anIterator);
if (gRootPort) CFRunLoopAddSource(CFRunLoopGetCurrent (),IONotificationPortGetRunLoopSource(notify),kCFRunLoopDefaultMode);


I do get kIOMessageCanSystemSleep when the system is put to sleep.

It could be that my daemon gets killed before I get the kIOMessageSystemWillRestart message.

Is there a better way to find out if the machine is restarted?

Thanks,

Martin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.