I have a late 2011 Macbook pro, and lately it hasn't been sleeping properly. If I close the lid for less than a minute and reopen it, it doesn't go to sleep while the lid is closed. The screen is still displayed immediately after reopening. Also, a few seconds after I open the machine, it will go to sleep on it's own. I have had the software checked and that doesn't seem to be the problem. What could be causing this and how do I get it fixed? It is still under warranty.


Solution 1:

If there is a process that is preventing sleep (rather than a bug in the sleep implementation), you can use "pmset -g" in a terminal window to list the process that is doing that. This is covered over on superuser.

Here is an an example on my system. First, with nothing preventing sleep:

$ pmset -g assertions | egrep '(PreventUserIdleSystemSleep|PreventUserIdleDisplaySleep)'
     PreventUserIdleDisplaySleep             0
     PreventUserIdleSystemSleep              0
$

Then I start music in iTunes:

$ pmset -g assertions | egrep '(PreventUserIdleSystemSleep|PreventUserIdleDisplaySleep)'
     PreventUserIdleDisplaySleep             0
     PreventUserIdleSystemSleep              1
    pid 264: [0x0000012c00000108] PreventUserIdleSystemSleep named: "com.apple.audio.'AppleHDAEngineOutput:1B,0,1,2:0'.noidlesleep" 
    pid 95390: [0x0000012c0001749e] PreventUserIdleSystemSleep named: "Nameless (via IOPMAssertionCreate)"