Linux – why new pid is smaller than the old ones

linuxprocess

Is there any chance the new process's pid is smaller than the existed ones ?
I have a daemon process which will restart when be killed, I recorded the pids,
and found that the pid first came smaller, and then go bigger.

what's the possible reason ?

===============================================================

sorry for asking & thanks for the answers.

I think I have found the answer.
/proc/sys/kernel/pid_max shows 32768(android os on a phone), in the longtime test, it must have exceeded this,and reallocated. Thanks again.

Best Answer

On Linux, PIDs are assigned in order, but eventually the system will hit its PID limit and start over, skipping already-assigned PIDs.

Related Question