kIOMessageSystemWillPowerOff not delivered to KEXT.
Hello. My problem is about catching shutdown/reboot from kext. I wrote kext, added registerSleepWakeInterest(&mySleepHandler, myself, NULL) where mySleepHandler logs something. it gets logged when system goes to sleep, but nothing gets logged when I try to restart system. Here is whole code: #include <sys/systm.h> #include <mach/mach_types.h> #include <IOKit/IOLib.h> #include <IOKit/pwr_mgt/RootDomain.h> #include <IOKit/pwr_mgt/IOPM.h> #include <IOKit/IOService.h> #include <IOKit/IONotifier.h> IONotifier *notifier; extern "C" { kern_return_t MyKext_start(kmod_info_t * ki, void *d); kern_return_t MyKext_stop(kmod_info_t *ki, void *d); IOReturn mySleepHandler( void * target, void * refCon, UInt32 messageType, IOService * provider, void * messageArgument, vm_size_t argSize ) { IOLog("Message type was %d\n", messageType); acknowledgeSleepWakeNotification(refCon); return 0; } kern_return_t MyKext_start(kmod_info_t * ki, void *d) { printf("MyKext has started.\n"); void *myself = NULL; // Would pass the self pointer here if in a class instance notifier = registerSleepWakeInterest(&mySleepHandler, myself, NULL); return KERN_SUCCESS; } kern_return_t MyKext_stop(kmod_info_t *ki, void *d) { printf("MyKext has finished.\n"); return KERN_SUCCESS; } } what's wrong? comment under kIOMessageSystemWillPowerOff says: * Indicates an imminent system shutdown. Recipients have a limited * amount of time to respond, otherwise the system will timeout and * shutdown even without a response. * Delivered to in-kernel IOKit drivers via <code>IOService::systemWillShutdown()</code>, * and to clients of <code>registerPrioritySleepWakeInterest()</code>. * Never delivered to user space notification clients. _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.... This email sent to site_archiver@lists.apple.com
participants (1)
-
Jani Baramidze