nitin_cherian
nitin_cherian

Reputation: 6655

Multiple processes with the same name

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?

Upvotes: 3

Views: 9537

Answers (4)

udslk
udslk

Reputation: 529

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

Upvotes: 0

MarcH
MarcH

Reputation: 19756

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.

Upvotes: 0

darioo
darioo

Reputation: 47183

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.

Upvotes: 0

MarkR
MarkR

Reputation: 63538

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.

Upvotes: 6

Related Questions