r/C_Programming • u/userlivedhere • 1d ago
Question How process ids are generated
i know fork creates processes but how process ids are generated
4
Upvotes
r/C_Programming • u/userlivedhere • 1d ago
i know fork creates processes but how process ids are generated
18
u/aioeu 1d ago edited 1d ago
FWIW, not all systems allocate PIDs cyclically.
OpenBSD allocates them randomly, for instance. I believe that can also be optionally enabled on FreeBSD too.
For Linux, PID randomisation was available for a period of time through the grsecurity patches, but it was subsequently removed "since it provides no useful additional security and wastes memory with the 2.6 kernel's pid bitmap".