2

Process Ids are generated in such a way that they're unique and tend to either increment, wrapping at some point, or be randomly generated, as far as I can tell. It seems there's a small but real risk that if you get the PID of a process and don't kill it immediately then that process could terminate and the PID be more or less immediately recycled, and you could therefore end up killing the wrong process. I'm not aware of any rule that says the the OS definitely won't reuse a PID within n seconds. Isn't this a risk?

1 Answer 1

2

The PID assigment occurs by an incremental counter (+1) starting at 0 and usually wrapping at around 60000-65000. You won't have to worry about accidentally killing a process which is already assigned the previous PID, it would take a considerate amount of time before the system reuses it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy