How do you see what a process is doing right now without restarting it?
AdvancedConceptProcesses, Signals & systemd
Answer
cat /proc/1234/wchan; echo # kernel function it's sleeping in
sudo cat /proc/1234/stack # kernel stack
sudo strace -p 1234 -f -tt # live syscalls
sudo ls -l /proc/1234/fd # files and sockets
sudo gdb -p 1234 -batch -ex 'thread apply all bt' # user stacks (pauses it)
For JVMs use jcmd <pid> Thread.print; for Python, py-spy dump --pid.
More on Processes, Signals & systemd
What is the difference between a program, a process and a thread?BeginnerHow are new processes created in Linux?IntermediateWhat is a zombie process, and how do you get rid of it?IntermediateWhat is an orphan process?BeginnerExplain the process states shown in ps (R, S, D, T, Z).IntermediateWhy can't you kill a process in D state?Advanced