Can a child process generated by "fork()" ever have a process id lesser than its parent?
Can a child process generated by "fork()" ever have a process id lesser than its parent? linux
linux
Yes. PIDs are not guaranteed to be in any order. Some systems and some security extensions generate random PIDs to avoid attacks based on child PID prediction. Of course even systems that linearly generate PIDs need to wrap around at some point.
Yes, the PIDs are reused after crossing the maximum limit (which depends on the OS and possibly configuration). So it's definitely possible provided the system is starting processes frequently enough.