You are not logged in.

#1 2022-11-16 12:51:55

Nick_Name
Member
Registered: 2022-11-07
Posts: 18

[SOLVED] Really stupid question about PID's

systemd a.k.a PID 1
Why next PID is 414 (on my system, systemd-journald).
So, why system does not use 2-413 PID's and starts next ID from 414?

Thank you

Last edited by Nick_Name (2022-11-16 17:15:56)

Offline

#2 2022-11-16 13:14:50

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,261

Re: [SOLVED] Really stupid question about PID's

PIDs aren't reset in between runs, so programs that got started and quit and did not leave a program lingering will have relevantly incremented that count until the next "longer running" program started.

Offline

#3 2022-11-16 13:26:50

Nick_Name
Member
Registered: 2022-11-07
Posts: 18

Re: [SOLVED] Really stupid question about PID's

V1del wrote:

PIDs aren't reset in between runs, so programs that got started and quit and did not leave a program lingering will have relevantly incremented that count until the next "longer running" program started.

Thank you for your explanation!

Offline

#4 2022-11-16 14:01:55

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,480
Website

Re: [SOLVED] Really stupid question about PID's

Also keep in mind that PID stands for process identifier not program identifier.  There are a boatload of kernel processes that will occupy much of the low-numbered PID space - many of them *are* still running even if your lowest numbered user-space program is 414.  See the output of `ps ax` to see many of these other processes.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2022-11-16 14:13:11

frostschutz
Member
Registered: 2013-11-15
Posts: 1,647

Re: [SOLVED] Really stupid question about PID's

Re-using pids early could cause some race conditions... lots of programs only check if pid is still running, and don't check if it's really still the same process.

Even in the short time between determining the pid of a process, and checking other properties of that pid, the process could already have ended and then it would be bad if another process took over that pid immediately.

So pids are not reused (or as late as possible). The max value is /proc/sys/kernel/pid_max

Offline

#6 2022-11-16 14:20:19

Nick_Name
Member
Registered: 2022-11-07
Posts: 18

Re: [SOLVED] Really stupid question about PID's

Trilby, frostschutz

Thank you!

Offline

#7 2022-11-16 14:27:09

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,261

Re: [SOLVED] Really stupid question about PID's

If you consider the question sufficiently answered, please remember to mark the topic as [SOLVED] by editing the title in your first post

Offline

#8 2022-11-16 17:15:36

Nick_Name
Member
Registered: 2022-11-07
Posts: 18

Re: [SOLVED] Really stupid question about PID's

V1del wrote:

If you consider the question sufficiently answered, please remember to mark the topic as [SOLVED] by editing the title in your first post

ok, understood

Offline

Board footer

Powered by FluxBB