I noticed that the PID of the processes my webapp is spawning keeps getting larger over time.
For each process, the PID is stored in a file to reference from the web app. I originally had a file buffer of 8 bytes to read the PID from.. While 8 bytes is probably enough, I’m noticing i may need to increase this buffer size if these numbers go up over a long period of time..
Do PID values ever get lower? Or only after a reboot and it starts over again?
What should my buffer size be if I’m reading a single PID value from a file? Should I just set a very large buffer?
On most operating systems, PID’s wrap around to 0 after 65535. It is not a safe assumption to assume that pid’s will only grow larger.
In principle, a pid could be any non-negative
pid_t, which on GNU systems is anint, sowould be the largest such pid even theoretically possible.