Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are some processes shown in pstree not shown in ps -ef?

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$ 
like image 378
Zii Avatar asked Aug 29 '14 11:08

Zii


People also ask

Does pstree show all processes?

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.

How do you read pstree?

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.

Which of the following describes things pstree can display?

The pstree command displays the running processes in the form of a tree structure.

Which process is the ancestor of all running processes on your system?

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.


1 Answers

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.

like image 160
ams Avatar answered Oct 01 '22 09:10

ams