As title, I run the above commands in sh shell of Linux, but I just cannot find the the child processes of pid 7459 by running "ps -ef | grep dummy". Can someone explain why there could be such difference between these 2 commands? They are active processes ,not LWP(thread), right? How can I display the threads,btw?
sh-3.2$ pstree -p 7459
dummy(7459)-+-{dummy}(7508)
|-{dummy}(7528)
|-{dummy}(7529)
|-{dummy}(7530)
|-{dummy}(7551)
|-{dummy}(7552)
|-{dummy}(7553)
`-{dummy}(7554)
sh-3.2$ ps -ef | grep dummy
root 7459 7167 0 Aug28 ? 00:09:13 /usr/bin/dummy
erv 23720 17254 0 13:22 pts/4 00:00:00 grep dummy
sh-3.2$
pstree shows running processes as a tree. The tree is rooted at either pid or init if pid is omitted. If a user name is specified, all process trees rooted at processes owned by that user are shown.
Pstree command in Linux that shows the running processes as a tree which is a more convenient way to display the processes hierarchy and makes the output more visually appealing. The root of the tree is either init or the process with the given pid. Pstree can also be installed in other Unix systems.
The pstree command displays the running processes in the form of a tree structure.
Process 0 is a special process that is created when the system boots; after forking a child process (process 1), process 0 becomes the swapper process (sometimes also known as the "idle task"). Process 1, known as init, is the ancestor of every other process in the system.
As @nos has already said, pstree
displays threads by default, but ps -ef
does not.
ps
can show threads, you just didn't ask it to. Try this (it might depend what version you have):
ps -eLf
This is all in the man page.
Linux threads are merely processes that share the same address space as another process. It's like a fork that didn't break away cleanly. You can read more in the clone
syscall documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With