2

I am running Ubuntu 20.04. According to https://lwn.net/Articles/531419/ and https://stackoverflow.com/questions/3446727/how-does-linux-determine-the-next-pid/3457108#3457108, assigned PIDs should be sequential. However, that is not the case with my newly created PID namespace where the first process has PID 1 (as it should) and the next process has PID 8. What is strange is that every PID after PID 8 is sequentially assigned.

$ sudo unshare --fork --pid --mount-proc bash
root@anon:/home/anon# ps aux
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.0   9844  3840 pts/2    S    12:13   0:00 bash
root           8  0.0  0.0  11500  3364 pts/2    R+   12:13   0:00 ps aux

Other processes after are assigned 9, 10, 11 ...

I'm curious why the initial jump from 1 to 8? If there are additional processes being created and killed before ps aux can be run that are occupying PIDs 2-7, how do I view what those are? I tried viewing /var/log/syslog but couldn't find anything useful.

1 Answer 1

4

I'm curious why the initial jump from 1 to 8?

When you start Bash in interactive mode, rc files (~/.bashrc, ~/.profile if login shell, and corresponding system-wide files in /etc) are read and executed before giving you a prompt.

If you execute bash --norc those rc files won't be executed and your ps command will have PID 2 as expected.

If there are additional processes being created and killed before ps aux can be run that are occupying PIDs 2-7, how do I view what those are?

Execute bash -x

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.