Search code examples
linuxprocesspid

Are process IDs assigned sequentially in Linux?


If a program has a process ID of P, will the child processes (and their children) have process IDs which are strictly greater then P?

When process IDs are reused, which process IDs are chosen e.g., is the lowest process ID available?


Solution

  • From http://en.wikipedia.org/wiki/Process_identifier

    Process IDs are usually allocated on a sequential basis, beginning at 0 and rising to a maximum value which varies from system to system. Once this limit is reached, allocation restarts at 300 and again increases. In Mac OS X and HP-UX, allocation restarts at 100. However, for this and subsequent passes any PIDs still assigned to processes are skipped. Some consider this to be a potential security vulnerability in that it allows information about the system to be extracted, or messages to be covertly passed between processes. As such, implementations that are particularly concerned about security may choose a different method of PID assignment.[1] On some systems, like MPE/iX, the lowest available PID is used, sometimes in an effort to minimize the number of process information kernel pages in memory.

    Original answer: https://superuser.com/questions/135007/how-are-pids-generated