bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

genpid() will never wrap


From: Marcus Brinkmann
Subject: genpid() will never wrap
Date: Thu, 2 Aug 2001 05:10:59 +0200
User-agent: Mutt/1.2i

Hi,

what's genpid() in proc/mgt.c supposed to do?
My impression is it should use pids up to 30000 in sequence, and
then try to reuse old pids.  Only if 30000 (60000, etc) processes take up all
pids it should expand to 60000 (12000, etc) and use those higher pids.

However, the current implementation checks freepid() before checking if
pid is higher than WRAP.  Because everytime genpid() is called
nextpid is increased by one, this will always lead to a new pid, which is
free because it is the first time this number is used.

The while block will never be entered.  I am not sure what happens
when nextpid wraps overruns INT_MAX.  Maybe libihash will segfault,
maybe it will survive and at some time nextpid will indeed be bigger than
wrap, but it doesn't seem to be what is intended anyway.

To make the function behave like described above, it needs to be rewritten
a bit. 

Thanks,
Marcus




reply via email to

[Prev in Thread] Current Thread [Next in Thread]