MacOS – Can’t restart because OS X thinks an app is open

dockmacosrestart

I was working with Xcode and it stopped responding so I force quit, reported the error, and tried reopening the app. When reopening the dock hung too so I ended up having to restart the dock with killall -KILL Dock. Unfortunately now OS X thinks Xcode is running but hung. Long pressing the icon in the dock or going to the force quit screen clearly show the app but selecting "Force Quit" does nothing and the app does not appear when I do ps -e.

Screenshot showing Xcode open but no result from <code>ps</code>.

Is there any way I can get OS X to realize the app isn't running so I can open it or safely restart the OS?

Best Answer

This bug occurs occasionally for me, and the ‘safest’ workaround I've found which I use is to quit all other open apps, then quit (not force quit) WindowServer. This logs out the current user without taking regard for apps which desire to interrupt this process, or apps which the OS still believe are running.

                         

According to an Apple Support Communities thread, this problem is caused by the kernel:

If "killall -KILL process_name" or "kill -KILL process_pid_number" does not kill the process, then that process is hung in the kernel, as a kill signal cannot be delivered until the process returns from kernel space to user space.

Source: https://discussions.apple.com/message/26762830?tstart=0#26762830

…but I'm not certain how accurate this is. Certain apps seem to exhibit this behaviour more often than others and I am yet to find a link as to what the actual cause of the problem/bug is.