Multiple processes with the same name

本秂侑毒 提交于 2019-12-07 17:07:28

问题


I have an application running on Linux 2.6.13 and WindRiver Linux 3.0. In Linux 2.6.13 when I do...

ps -eaf | grep myapplication

...the output shows multiple entries of 'myapplication'.

If I give the same command in WindRiver Linux 3.0, the output shows only one entry of 'myapplication'

Is the difference related to the difference in OS used? Kindly tell me the reason for this?


回答1:


It's probably related to the threading library in use and/or kernel version.

The old (now very old) "Linuxthreads" threading library, used to show each thread as a "top-level" process, which would appear directly under /proc and have a distinct PID. This was one of its many drawbacks, which were fixed by:

The new (now not very new) "NPTL" threading library, which has for many years been included in every new distribution, can use kernel features to make the threads appear under the same PID. The threads are still there but are now under a "task" subdirectory in /proc so are normally ignored by "ps" (You can still see them if you want, with an appropriate option).

Both libraries implement the posix threads API (more-or-less; newer ones do more than the older ones). I expect the processes in question were multithreaded.

It is still possible to see programs linked with Linuxthreads if they were statically linked a long, long time ago. Modern kernels support this just fine.




回答2:


Perhaps grep myapplication is also listed and that's why there are multiple entries. If not, it depends on what your application is doing, perhaps calling itself etc. You'll need to provide more information, or at least ps -eaf | grep myapplication output.




回答3:


In Linux the implementation of a thread is not very different from a full process, see man clone. I suspect you are just using two different ps commands with a different default setting. ps --help will show you how to list every thread of every process.




回答4:


You can use "ps -efm" to list the processes and threads associated with them. Some systems show threads with the same name as the executable. There you'll see kernel threads are shown with "[ ]".



来源:https://stackoverflow.com/questions/4145318/multiple-processes-with-the-same-name

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!