Multiple processes with the same name

不羁岁月 提交于 2019-12-06 03:49:33

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.

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.

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.

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 "[ ]".

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