title: After IORegisterForSystemPower failing to call IODeregisterForSystemPower
body: <p>I have an application, written in Objective-C for MacOS 10.10+ which registers for sleep/wake notifications (code sample below, but the code isn't the question). What I am wondering is, if I call IORegisterForSystemPower at App initialisation, but during debugging I kill the app before it has a chance to call IODeregisterForSystemPower, what are the implications? Does the app get de-registered automatically when it dies in any case? Is there a system dictionary I need to clear out (a plist somewhere, etc.)? Thanks in advance for any help.</p>
  <pre><code>io_object_t                 root_notifier = MACH_PORT_NULL;
  IONotificationPortRef       notify = NULL;
  
  DebugLog(@&quot;App: Logging IORegisterForSystemPower sleep/wake notifications %@&quot;, [NSDate date]);
  
  /* Log sleep/wake messages */
  powerCallbackPort = IORegisterForSystemPower ((__bridge void *)self, &amp;notify, sleepWakeCallback, &amp;root_notifier);
  if ( powerCallbackPort == IO_OBJECT_NULL ) {
      DebugLog(@&quot;IORegisterForSystemPower failed&quot;);
      return;
  }
  
  self.rootNotifierPtr = &amp;(root_notifier);  // MARK: deregister with this pointer
  
  if ( notify &amp;&amp; powerCallbackPort )
  {
      CFRunLoopAddSource(CFRunLoopGetCurrent(),IONotificationPortGetRunLoopSource(notify), kCFRunLoopDefaultMode);
  }
  </code></pre>