diff options
author | Dan Moschuk <dan@FreeBSD.org> | 1999-11-28 17:51:09 +0000 |
---|---|---|
committer | Dan Moschuk <dan@FreeBSD.org> | 1999-11-28 17:51:09 +0000 |
commit | ee3fd60126538da89df815fb30cd5230eee368e0 (patch) | |
tree | c7fa883b8e974720a05a8bf4d1855cd9cb97a488 /sys/kern/kern_fork.c | |
parent | ee072c08d05f833fc06d18e6804f2b770978909e (diff) |
Notes
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r-- | sys/kern/kern_fork.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index c12c965f7b69..9f3feb29f4bb 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -142,6 +142,9 @@ rfork(p, uap) int nprocs = 1; /* process 0 */ static int nextpid = 0; +static int randompid = 0; +SYSCTL_INT(_kern, OID_AUTO, randompid, CTLFLAG_RW, &randompid, 0, ""); + int fork1(p1, flags, procp) struct proc *p1; @@ -262,8 +265,8 @@ retry: * restart somewhat above 0, as the low-numbered procs * tend to include daemons that don't exit. */ - if (nextpid >= PID_MAX) { - nextpid = 100; + if (nextpid >= PID_MAX || randompid) { + nextpid = (randompid) ? arc4random() % PID_MAX : 100; pidchecked = 0; } if (nextpid >= pidchecked) { |