1

I have a question about number of PIDs a process has in context of Linux PID namespaces.

Suppose: (NS = namespace)

P1 (PID NS1) -> clone -> P2 (PID NS2) -> clone -> P3 (PID NS3)

How many PIDs does P3 have ?

I think the following, but I'm not sure if its correct :

  • one for NS3
  • one for host
  • one for NS2
  • one for NS1

Thanks.

  • What's the purpose of the question? – Pavel Šimerda Apr 7 '14 at 19:05
  • Trying to confirm the answer, I'm not sure if 4 is correct. – Jake Apr 7 '14 at 19:06
4

By definition of a PID namespace, a process that exists in a namespace has a PID in that namespace, and a (different, except for coincidences) PID in each ancestor namespace. So a process in NS3 has 4 different PIDs: one in NS3, one in NS2, one in NS1, and one in the root namespace.

There is a good series of posts by Michael Kerrisk about namespaces on LWN — read in particular Part 3: PID namespaces and Part 4: more on PID namespaces.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.