How to use truss command to analyse process


Under some conditions, the process can go down without any apparent reason. There is typically no core file to analyze why the process goes down. In my case, I tried to show how to find sighup signal for a process. Also, you can check your process’ activity with truss command. Please check “man truss”.

Step 1: Create a dummy process to apply test action

#sleep 1000 &
[2] 16177
# ps -ef|grep 16177
testuser 16177 22161 0 09:57:38 pts/23 0:00 sleep 1000
NAME PID
Sleep Dumy Process 16177
SSHD Process 22161

Step 2:How to start truss for a specific Process
 

# truss -o /tmp/truss.out -sall -p 16177


Step 3: After starting truss, we can send “sighup” with close terminal.

“Break your SSH connection terminal, which “Sleep” command running.I meant disconnect session or close SSH session terminal”.

Step 4:Check Truss output file.

# cat /tmp/syslog.truss.out
nanosleep(0xFB53A628, 0xFB53A620) (sleeping…)
Received signal #1, SIGHUP, in nanosleep() [default]
siginfo: SIGHUP pid=22161 uid=1548235000 >> we observed that SIGHUP signal send by SSHD process. Because we closed SSH connection which PPID of “sleep” process.
nanosleep(0xFB53A628, 0xFB53A620) Err#4 EINTR

 

Tagged In:

I'm a IT Infrastructure and Operations Architect with extensive experience and administration skills and works for Turk Telekom. I provide hardware and software support for the IT Infrastructure and Operations tasks.

205 Total Posts
Follow Me