How to find out which operator is executing the current process

I have a process that suddenly hanged itself and does not give any main dump, nor is it killed. I see that it still works with the ps command.

how can I find out what operator it executes inside the code.

Mostly I want to know exactly where he was hanged.

The language is C ++, and the platform is unixis solaris.

demos.283> cat test3.cc #include<stdio.h> #include<unistd.h> int main() { sleep(100); return 0; } demos.284> CC test3.cc demos.285> ./a.out & [1] 2231 demos.286> ps -o "pid,wchan,comm" PID WCHAN COMMAND 23420 fffffe86e9a5aff6 -tcsh 2345 - ps 2231 ffffffffb8ca3376 ./a.out demos.290> ps PID TTY TIME CMD 3823 pts/36 0:00 ps 23420 pts/36 0:00 tcsh 3822 pts/36 0:00 a.out demos.291> pstack 3822 3822: ./a.out fed1a215 nanosleep (80478c0, 80478c8) 080508ff main (1, 8047920, 8047928, fed93ec0) + f 0805085d _start (1, 8047a4c, 0, 8047a54, 8047a67, 8047c05) + 7d demos.292> 
+4
source share
2 answers

you can try with pstack to pass pid as a parameter. You can use ps to get the process id (pid)

For example: pstack 1267

+3
source

You have several options: it is easiest to check the pending WCHAN channel that the process was sleeping on:

 $ ps -o "pid,wchan,comm" PID WCHAN COMMAND 2350 wait bash 20639 hrtime i3status 20640 poll_s dzen2 28821 - ps 

This can give you a good idea of ​​what the process is doing and is very easy to get.

You can use ktruss and ktrace or DTrace to track your process. (Sorry, there is no Solaris here, so no examples.)

You can also attach gdb(1) to your process:

 # gdb -p 20640 GNU gdb (Ubuntu/Linaro 7.2-1ubuntu11) 7.2 ... (gdb) bt #0 0x00007fd1a99fd123 in __select_nocancel () at ../sysdeps/unix/syscall-template.S:82 #1 0x0000000000405533 in ?? () #2 0x00007fd1a993deff in __libc_start_main (main=0x4043e3, argc=13, ubp_av=0x7fff25e7b478, ... 

Backtrace is often the most useful error report you can get from a process, so you should install gdb(1) if it is not already installed. gdb(1) can do a lot more than just show you backtracks, but the full tutorial goes beyond the overflow stack.

+7
source

Source: https://habr.com/ru/post/1382852/


All Articles