<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>

I believe it will just suspend all apps wherever they happen to be.
Remember, this happens all the time anyway.  Applications are constantly suspended and resumed due to context switching.  So, really, the clock could jump between any 2 instructions in your app, though usually not in a noticable/significant way.
If the OS waited for the app to return to some main loop you could run into situations where applications cause the sleep to hang.  If they're doing a lot of work and not returning to the run loop dispatcher they would prevent the machine from going to sleep.  That wouldn't be very good. :)