title: What happens to my app when my Mac goes to sleep?
body: <p>When Mac OS X goes to sleep, due to closing a laptop or selecting "Sleep" from the Apple menu, how does it suspend an executing process?</p>
  
  <p>I suppose non-windowed processes are simply suspended at an arbitrary point of execution.  Is that also true for Cocoa apps, or does the OS wait until control returns to the run loop dispatcher, and goes to sleep in a "known" location?  Does any modern OS do that, or is it usually safe enough to simply suspend an app no matter what it is doing?</p>
  
  <p>I'm curious, because allowing sleep to occur at any moment means, from the app's perspective, the system clock could suddenly leap forward by a significant amount.  That's a possibility I don't usually consider while coding.</p>