Can a child process generated by "fork()" ever have a process id lesser than its parent?

StackOverflow https://stackoverflow.com/questions/21635916

  •  08-10-2022
  •  | 
  •  

質問

Can a child process generated by fork() ever have a process id lesser than its parent(without crossing the maximum limit)?

The PID is usually the next available value but anyhow can it possibly be less than the parent's PID?

役に立ちましたか?

解決

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. PIDs are reused, and on some systems, PIDs do not necessarily increase monotonically.

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top