Benches macOS

11

How to identify stalled/stuck application…

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

Hi Folks,

I've had a few cases recently where "sudo reboot" didn't in fact reboot the machine, and I was still able to log back into the same machine remotely. As these were distant/remote machines, and I do tech support, I'd love to save myself a trip to their office a few miles away.

Going to the Apple menu > Force Quit, shows me in red type "stuck" applications, or "application not responding" and I'm able to then force quit them. But that's if you're logged in.

However, in Terminal, I don't know of a way to identify the application and/or daemon, or Launchd program causing the problem. If I did, presumably "sudo kill" could then be used to kill the item in question...

Any ideas/suggestions?

Thanks, Lurch

11 replies

Sign in or join Beachball Help to reply.

  1. 0

    Tony T1

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    top will report a 'stuck' process.

    I have a know app that always needs a force-quit, and top reports:

    Processes: 57 total, 2 running, 1 stuck, 54 sleeping, 236 threads

  2. 0

    Tony T1

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    You can also try ps and look for a U


    ps ax | grep 'U '

    state The state is given by a sequence of characters, for example,
    ``RWNA''. The first character indicates the run state of the
    process:
    I Marks a process that is idle (sleeping for longer than
    about 20 seconds).
    R Marks a runnable process.
    S Marks a process that is sleeping for less than about 20
    seconds.
    T Marks a stopped process.
    U Marks a process in uninterruptible wait.
    Z Marks a dead process (a ``zombie'').
    Additional characters after these, if any, indicate additional
    state information:

  3. 0

    roam

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Have you noticed Tony, that Mail is always shown as stuck. I find that curious.

  4. 0

    Tony T1

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    roam wrote:

    Have you noticed Tony, that Mail is always shown as stuck. I find that curious.

    Not on my system, though I have noticed Safari reported as 'stuck' for about a second, then it clears on its own.

  5. 0

    BobHarris

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    'U' - uninterruptable does not mean stuck, stalled, nor hung.

    It just seems that programs which happen to be stuck, stalled, or hung happen to be in 'U' uninterruptable mode.

    'U' uninterruptable just means that at this moment any signals sent to the process will be queued and not delivered until the process transistions from kenel code to user code. If the process never leaves kernel code, the signal will not be delivered.

    Kernel code & kernel level drivers can make calls that check for signals and attempt to stop what they are doing and return to user code so that signals can be delivered, but that is generally limited to slow I/O operations (waiting for user typed input, network I/O), as most kernel operations are quick and limited in how long they last.

    However, not all kernel things which should complete quickly always do, so they can become stuck in an 'U' uninterruptable state.

  6. 0

    roam

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Tony,

    Thanks for your response.

    I invariably have 1 stuck

    eg. Processes: 49 total, 2 running, 1 stuck, 46 sleeping... 232 threads

    The '1 stuck' is removed when I close Mail and reappears when I open it.

    In 10.3 top shows nothing stuck with Mail open. When I click 'Get mail' it will flash 'stuck' for about a second too as you report with Safari. This seems normal. However on my Leopard it is always on.

    BobHarris,

    Thanks for your detailed response about kernel states.

    Observing '1 stuck' process, I tracked it down to Mail using ps aux

    It was the only one in the U state. Closing Mail removes the stuck notice, as mentioned to Tony.

    Mail appears to work correctly.

    If it is not really stuck I wish Leopard's top would not report it as such.

    You are on 10.5.8 as well. Is you Mail reported as stuck or not (erroneously or otherwise)?

  7. 0

    Jun T.

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Yes, Mail.app is always in the U-state on my 10.5.8 iMac, but on 10.6.2 it is in the U-state only when it is downloading mails from remote servers.

    ps counts a process as uninterruptible (U) if at least one thread of the process is in the U state. You can see this by adding an option "-M" to the ps command line. But having an U thread does not mean the whole process is "stuck".

    The "Force Quit" menu, or the Activity Monitor.app, does not mark Mail.app as "not responding", of course. So they are using a different method to identify "stuck" processes. But I don't know whether there is a command line tool which can do the same identification.

  8. 0

    roam

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Thanks Jun T.

    So it appears to be an idiosyncrasy of 10.5.8 (or Mail 3.6)

    I was not very concerned, more wondering really. First seeing it, kind of demanded attention as in 'what's stuck?' When I found it was Mail, I accepted it as a vagary of Mail 3.6 and it was only seeing this topic that prompted me to mention it.

    At least I am happy to know it's a 10.5 thing and not particular to my Mail.

  9. 0

    Obj-D

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Hi,

    Then I have a question, what about the Z state?

    Are there any caveats, are they stuck or also temporally unavailable?

    Is it safe to kill them?

    Earlier I had two, but now one.

    24523 ?? Z 0:00.00 (thnuclnt)

    Is the OS removing those by it selfs or...

  10. 0

    hondamusprime

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    is your stuck process VMWare?

    this may be incorrect, but wouldn't a *sudo shutdown -r now* reboot the system even if some processes are stuck?

    the shutdown command is supposed to interrupt launchd if I am remembering correctly. Shutdown sends a SIGTERM, then a SIGKILL.

    Usually Z status items are trying to set or read their exit status. Zombie processes have completed, so in most cases is should be ok to kill them.

    http://en.wikipedia.org/wiki/Zombie_process

  11. 0

    BobHarris

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    A 'Z' Zombie process is a terminated process that has given up just about all of its resources (which is why it is called a Zombie, as it is just a shell of its former self), except for a small amount of process state containing its exit status that it is try give to its parent process.

    As far as I know you cannot kill a Zombie process, as there is nothing to kill and besides a killed process still needs to report is compltion status to its parent process.

    It is the responsibility of the parent process to "Reap" the completion status of any child process it creates. There are various programming ways a parent process can do this, but it is still the parent process' responsibility.

    As an alternative, you can kill the parent process, then all of the the parent process' children become "Orphans" (including the Zombies), and Orphaned processes are adopted by process PID 1, which on Mac OS X is launchd (it is called 'init' on other flavors of Unix/Linux). launchd will then 'Reap' the Zombie childs completion status and allow the process to go away.

    You can use Activity Monitor to in an "All Processes, Hierarchically" display.