summaryrefslogtreecommitdiff
path: root/proc
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1994-10-14 09:00:43 +0000
committerRoland McGrath <roland@gnu.org>1994-10-14 09:00:43 +0000
commitc73d4c832c3038c60c6ccffacfb2301051ec4570 (patch)
tree02978ee780a1271d48989dca7c964eb6660ed305 /proc
parent00a20bf1fba0a63f86cae462dc5899ee8da19d0e (diff)
Formerly mgt.c.~21~
Diffstat (limited to 'proc')
-rw-r--r--proc/mgt.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/proc/mgt.c b/proc/mgt.c
index be969132..aca3e151 100644
--- a/proc/mgt.c
+++ b/proc/mgt.c
@@ -463,7 +463,7 @@ new_proc (task_t task)
mach_port_request_notification (mach_task_self (), p->p_task,
MACH_NOTIFY_DEAD_NAME, 1, p->p_reqport,
MACH_MSG_TYPE_MAKE_SEND_ONCE, &foo);
- if (foo)
+ if (foo != MACH_PORT_NULL)
mach_port_deallocate (mach_task_self (), foo);
@@ -689,13 +689,29 @@ add_tasks (task_t task)
int
genpid ()
{
- static int nextpid = 0;
-
#define WRAP_AROUND 30000
#define START_OVER 100
+ static int nextpid = 0;
+ static int wrap = WRAP_AROUND;
+
+ int wrapped = 0;
+
+ while (!pidfree (nextpid))
+ {
+ ++nextpid;
+ if (nextpid > wrap)
+ {
+ if (wrapped)
+ {
+ wrap *= 2;
+ wrapped = 0;
+ }
+ else
+ {
+ nextpid = START_OVER;
+ wrapped = 1;
+ }
+ }
- while (!pidfree (nextpid)
- && ((++nextpid > WRAP_AROUND) || (nextpid = START_OVER)))
- ;
return nextpid++;
}