Source: http://www.xymyeah.com/979.html
1. pstree
Pstree displays processes in a tree structure
$ Pstree-P work | grep ad
Sshd (22669) --- bash (22670) --- ad_preprocess (4551)-+-{ad_preprocess} (4552)
|-{Ad_preprocess} (4553)
|-{Ad_preprocess} (4554)
|-{Ad_preprocess} (4555)
|-{Ad_preprocess} (4556)
'-{Ad_preprocess} (4557)
Work is the working user,-P is the display process identifier, ad_preprocess has started 6 sub-threads, and a total of 7 main threads
2. PS-lf
$ PS-lf 4551
Uid pid ppid lwp C nlwp stime tty stat time cmd
Work 4551 22670 4551 2 7 pts/2 SL +./ad_preprocess
Work 4551 22670 4552 0 7 pts/2 SL +./ad_preprocess
Work 4551 22670 4553 0 7 pts/2 SL +./ad_preprocess
Work 4551 22670 4554 0 7 pts/2 SL +./ad_preprocess
Work 4551 22670 4555 0 7 pts/2 SL +./ad_preprocess
Work 4551 22670 4556 0 7 pts/2 SL +./ad_preprocess
Work 4551 22670 4557 0 7 pts/2 SL +./ad_preprocess
A total of 7 threads are started.
3. pstack
Pstack displays the stack trace of each process
$ Pstack 4551
Thread 7 (thread 1084229984 (lwp 4552 )):
#0 0x000000302afc63dc in epoll_wait () from/lib64/tls/libc. so.6
#1 0x000000000000006f0730 in UB: epollex: poll ()
#2 0x00000000006f172a in UB: netreactor: callback ()
#3 0x000000000000006fbbbb in UB: ubtask: callback ()
#4 0x000000302b80610a in start_thread () from/lib64/tls/libpthread. so.0
#5 0x000000302afc6003 in clone () from/lib64/tls/libc. so.6
#6 0x0000000000000000 in ?? ()
Thread 6 (thread 1094719840 (lwp 4553 )):
#0 0x000000302afc63dc in epoll_wait () from/lib64/tls/libc. so.6
#1 0x000000000000006f0730 in UB: epollex: poll ()
#2 0x00000000006f172a in UB: netreactor: callback ()
#3 0x000000000000006fbbbb in UB: ubtask: callback ()
#4 0x000000302b80610a in start_thread () from/lib64/tls/libpthread. so.0
#5 0x000000302afc6003 in clone () from/lib64/tls/libc. so.6
#6 0x0000000000000000 in ?? ()
Thread 5 (thread 1105209696 (lwp 4554 )):
#0 0x000000302b80baa5 in _ nanosleep_nocancel ()
#1 0x000000000079e758 in comcm: ms_sleep ()
#2 0x00000000006c8581 in UB: ubclientmanager: healthycheck ()
#3 0x000000000000006c8471 in UB: ubclientmanager: start_healthy_check ()
#4 0x000000302b80610a in start_thread () from/lib64/tls/libpthread. so.0
#5 0x000000302afc6003 in clone () from/lib64/tls/libc. so.6
#6 0x0000000000000000 in ?? ()
Thread 4 (thread 1115699552 (lwp 4555 )):
#0 0x000000302b80baa5 in _ nanosleep_nocancel ()
#1 0x00000000000000482b0e in armor: armor_check_thread ()
#2 0x000000302b80610a in start_thread () from/lib64/tls/libpthread. so.0
#3 0x000000302afc6003 in clone () from/lib64/tls/libc. so.6
#4 0x0000000000000000 in ?? ()
Thread 3 (thread 1126189408 (lwp 4556 )):
#0 0x000000302af8f1a5 in _ nanosleep_nocancel () from/lib64/tls/libc. so.6
#1 0x000000302af8f010 in sleep () from/lib64/tls/libc. so.6
#2 0x000000000044c972 in business_config_manager: Run ()
#3 0x0000000000457b83 in thread: run_thread ()
#4 0x000000302b80610a in start_thread () from/lib64/tls/libpthread. so.0
#5 0x000000302afc6003 in clone () from/lib64/tls/libc. so.6
#6 0x0000000000000000 in ?? ()
Thread 2 (thread 1136679264 (lwp 4557 )):
#0 0x000000302af8f1a5 in _ nanosleep_nocancel () from/lib64/tls/libc. so.6
#1 0x000000302af8f010 in sleep () from/lib64/tls/libc. so.6
#2 0x00000000004524bb in process_thread: sleep_period ()
#3 0x0000000000452641 in process_thread: Run ()
#4 0x0000000000457b83 in thread: run_thread ()
#5 0x000000302b80610a in start_thread () from/lib64/tls/libpthread. so.0
#6 0x000000302afc6003 in clone () from/lib64/tls/libc. so.6
#7 0x0000000000000000 in ?? ()
Thread 1 (thread 182894129792 (lwp 4551 )):
#0 0x000000302af8f1a5 in _ nanosleep_nocancel () from/lib64/tls/libc. so.6
#1 0x000000302af8f010 in sleep () from/lib64/tls/libc. so.6
#2 0x0000000000420d79 in ad_preprocess: Run ()
#3 0x000000000000000000ad0 in main ()
Source: Internet chronicle http://www.xymyeah.com/979.html.