r/C_Programming • u/userlivedhere • Sep 01 '26
Question How process ids are generated
i know fork creates processes but how process ids are generated
6
Upvotes
r/C_Programming • u/userlivedhere • Sep 01 '26
i know fork creates processes but how process ids are generated
View all comments
Show parent comment
18
u/aioeu Sep 01 '26 edited Sep 01 '26
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".