Bash – Debugging hanging bash process

bashtroubleshooting

After some bad performance today, I checked top:

 1  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
  14229 myuser    20   0  8776 5264 1684 R   99  0.2   1383:47 bash

98-100% use by a Bash process which should have died a long time ago (I just closed all terminals to verify it)? I'm not sure what's causing it.

$ lsof -p 14229
COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF     NODE NAME
bash    14229 myuser  cwd    DIR   0,23     4096 11059271 /home/users/myuser (company.com:/home/users/)
bash    14229 myuser  rtd    DIR    8,2     4096        2 /
bash    14229 myuser  txt    REG    8,2   920788  7617113 /bin/bash
bash    14229 myuser  mem    REG    8,2    30520   657679 /lib/i386-linux-gnu/libnss_compat-2.15.so
bash    14229 myuser  mem    REG    8,2    13940   657672 /lib/i386-linux-gnu/libdl-2.15.so
bash    14229 myuser  mem    REG    8,2  1713640   657666 /lib/i386-linux-gnu/libc-2.15.so
bash    14229 myuser  mem    REG    8,2   121024   660635 /lib/i386-linux-gnu/libtinfo.so.5.9
bash    14229 myuser  mem    REG    8,2    47040   657683 /lib/i386-linux-gnu/libnss_files-2.15.so
bash    14229 myuser  mem    REG    8,2    42652   657690 /lib/i386-linux-gnu/libnss_nis-2.15.so
bash    14229 myuser  mem    REG    8,2   134344   657659 /lib/i386-linux-gnu/ld-2.15.so
bash    14229 myuser  mem    REG    8,2    92016   657678 /lib/i386-linux-gnu/libnsl-2.15.so
bash    14229 myuser  mem    REG    8,2  2919792  7748495 /usr/lib/locale/locale-archive
bash    14229 myuser  mem    REG    8,2    26256  7757442 /usr/lib/i386-linux-gnu/gconv/gconv-modules.cache
bash    14229 myuser    0r   CHR  136,1      0t0        4 /dev/pts/1 (deleted)
bash    14229 myuser    1w   CHR  136,1      0t0        4 /dev/pts/1 (deleted)
bash    14229 myuser    2w   CHR  136,1      0t0        4 /dev/pts/1 (deleted)
bash    14229 myuser  255u   CHR  136,1      0t0        4 /dev/pts/1 (deleted)

Except for the /dev/pts lines this is identical to other bash processes:

COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF     NODE NAME
bash    6674 myuser  cwd    DIR   0,23     4096 11059271 /home/users/myuser (company.com:/home/users/)
bash    6674 myuser  rtd    DIR    8,2     4096        2 /
bash    6674 myuser  txt    REG    8,2   920788  7617113 /bin/bash
bash    6674 myuser  mem    REG    8,2  1713640   657666 /lib/i386-linux-gnu/libc-2.15.so
bash    6674 myuser  mem    REG    8,2   121024   660635 /lib/i386-linux-gnu/libtinfo.so.5.9
bash    6674 myuser  mem    REG    8,2    47040   657683 /lib/i386-linux-gnu/libnss_files-2.15.so
bash    6674 myuser  mem    REG    8,2    13940   657672 /lib/i386-linux-gnu/libdl-2.15.so
bash    6674 myuser  mem    REG    8,2    30520   657679 /lib/i386-linux-gnu/libnss_compat-2.15.so
bash    6674 myuser  mem    REG    8,2    42652   657690 /lib/i386-linux-gnu/libnss_nis-2.15.so
bash    6674 myuser  mem    REG    8,2    92016   657678 /lib/i386-linux-gnu/libnsl-2.15.so
bash    6674 myuser  mem    REG    8,2   134344   657659 /lib/i386-linux-gnu/ld-2.15.so
bash    6674 myuser  mem    REG    8,2  2919792  7748495 /usr/lib/locale/locale-archive
bash    6674 myuser  mem    REG    8,2    26256  7757442 /usr/lib/i386-linux-gnu/gconv/gconv-modules.cache
bash    6674 myuser    0r   CHR  136,2      0t0        5 /dev/pts/2
bash    6674 myuser    1w   CHR  136,2      0t0        5 /dev/pts/2
bash    6674 myuser    2w   CHR  136,2      0t0        5 /dev/pts/2
bash    6674 myuser  255u   CHR  136,2      0t0        5 /dev/pts/2

Standard kill doesn't work:

$ kill 14229 && sleep 1m && kill -0 14229 && echo Alive
Alive

According to ps wafux it has no child processes.

Tried tracing it as recommended by @ChandraRavoori:

$ sudo strace -p 14229
Process 14229 attached - interrupt to quit

After that I get no output. I tried to kill 14229 multiple times, and it just printed the following every time:

--- SIGTERM (Terminated) @ 0 (0) ---

What are other things to check before kill -9?

Best Answer

Try

strace -p 14229

I will print every syscall that the process invokes. Then you see what the process actually does.

http://try-linux.blogspot.de/2013/12/how-to-strace-process.html

Related Question