Inspect what a program is doing when it seems to hang 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.?
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...

https://support.apple.com/guide/activity-monitor/quit-a-process-actmntr1002/10.14/mac/10.15

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.