Linux – Is a process PID guaranteed to stay the same as long as the process doesn’t die

linuxpidprocess

I'm doing some simulation work with Linux, and the code I'm working on right now only works under the assumption that, once a process has been assigned a PID by the kernel, that PID will remain the same until the process is killed. I would assume this is true but since I'm kind of new to the Linux world I just want to see if there are any special circumstances I ought to be aware of. Thanks!

Best Answer

Yes, it's guaranteed. Process will have the same PID even if its image will be replaced with another one by exec system call.

Related Question