PDA

View Full Version : About pids of father process/child process


angelo
03-10-2005, 03:14 AM
Can it be guaranteed that the pid of a process is always greater than
that of its children?

Roger Leigh
03-10-2005, 04:33 AM
angelo <mzhou@cs.hku.hk> writes:

> Can it be guaranteed that the pid of a process is always greater than
> that of its children?

Nope. The PID can wrap around once it reaches an upper limit. This
may vary depending on your kernel: some randomise the PID for
security, and IIRC the range was recently expanded, which means it may
wrap less often. It's certainly something that you need to allow for
in any case.


--
Roger Leigh
Printing on GNU/Linux? http://gimp-print.sourceforge.net/
Debian GNU/Linux http://www.debian.org/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.

Holger Petersen
03-10-2005, 04:58 AM
angelo <mzhou@cs.hku.hk> writes:

>Can it be guaranteed that the pid of a process is always greater than
>that of its children?

No.

Just think of "PID 32767" for the 'Father' (in a system with 2^15 max)
The 'son' will get something higer then "1" and lower then "32767". The
same holds true for any other system with a finite maximum PID...

Greetings, Holger