tags:

views:

99

answers:

1

On my system the lowest ID running right now is 1 (init). I'm making a small wrapper function around pidof and I was wondering, what is the lowest possible process ID a process can have?

The reason I ask is because I would like to return an integer from my function indicating "process was not running" (pidof itself returns an empty string in this case). I was thinking of using either 0 or -1, and I just want to make sure a real process could never have such IDs.

+5  A: 

PIDs are always positive, so both 0 and -1 are OK as non-PID sentinels. Several PID-related system calls, like wait() and kill(), assign special meaning to these values.

caf
Perfect, thanks. I'll use 0 so I can treat it as a bool.
Jake Petroules