How to know where a program is stuck in linux?

  • I am running the following command on my ubuntu server

    [email protected]:~# lxc-stop --name pavan --logfile=test1.txt --logpriority=trace

    It seems to hang indefinitely. Whenever this happened on AIX, I simply used to get the PID of the offending process and say

    $ procstack <pid_of_stuck_process>

    and it used to show the whole callstack of the process. Is there any equivalent of procstack in linux/ubuntu?

  • My first step would be to run strace on the process, best

     strace -s 99 -ffp 12345

    if your process ID is 12345. This will show you all syscalls the program is doing. How to strace a process tells you more.

    If you insist on getting a stacktrace, google tells me the equivalent is pstack. But as I do not have it installed I use gdb:

     tweedleburg:~ # sleep 3600 &
     [2] 2621
     tweedleburg:~ # gdb
     (gdb) attach 2621
     (gdb) bt
     #0  0x00007feda374e6b0 in __nanosleep_nocancel () from /lib64/
     #1  0x0000000000403ee7 in ?? ()
     #2  0x0000000000403d70 in ?? ()
     #3  0x000000000040185d in ?? ()
     #4  0x00007feda36b8b05 in __libc_start_main () from /lib64/
     #5  0x0000000000401969 in ?? ()

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM