1

Sometimes, programs (both GUI and CLI applications) will hang, and I don't really know what they are doing. The only thing I can do is to wait or kill them when I get impatient. Is there any way to inspect what these programs are doing, e.g. reading/writing files, system calls, waiting for something, etc.?

Joy Jin
  • 2,733

1 Answers1

3

Why yes you can inspect running programs. It’s technical, but very doable.

Open up the Activity Monitor and look for the program you see hanging. Select it with the mouse / pointer. Then click the gear and rather than forcing it to quit, choose System Diagnosis...

You should be presented with a pretty lengthy Privacy Notice, which I recommend everyone read and make screen capture if you want to read later. Then let the process run. It first gathers all the time-sensitive information about that specific process - what it’s doing, what memory it has asked for, what files and network connections it may have, then this tool packages all manner of very detailed information about just about everything on the system. Logs, errors, file systems, network setup, etc...

The main items to look at are the samples - and if this is something you wish to do often, you can even get Xcode which has an “instruments” app that attaches to running processes to look in to them and determine why they hang.

bmike
  • 235,889
  • How would I use instruments to examine this problem https://apple.stackexchange.com/questions/405048/how-can-i-debug-an-extremely-slow-login? (login in terminal takes a long time) Can I ask a new question on that or do I have to figure that out myself? – Joy Jin Nov 03 '20 at 07:57
  • The problem with system diagnosis is that it includes too much information and I don't really know where to look. – Joy Jin Nov 03 '20 at 08:05
  • Yes. It is a firehose of data, @JoyJin however it’s never clear which part of the firehose contains the clue. Asking follow on questions is highly encouraged. Do a little research to show how far you got using instruments and link here for context is my advice on how to use Instruments. (Or how to install it or launch it) – bmike Nov 03 '20 at 21:55