Apple - What's the maximum pid for Mac OS X?

Looking at sys/proc_internal.h in xnu-1699.24.23, I find that PID_MAX is 99999. The value is used in kern_fork.c in the function forkproc. Looking at that function, process IDs are not assigned equal to PID_MAX, so the highest possible pid is 99998.


Kyle's answer is still valid as of today. In case you want to verify that, here is a shell script:

#!/bin/bash

pid=0
for i in {1..100000}; do
  : &
  if [ $! -lt $pid ]; then
    echo "Min pid: $!"
    echo "Max pid: $pid"
    break
  fi
  pid=$!
done

This prints:

Min pid: 100
Max pid: 99998

Tags:

Kernel