Fix a corner case in ID bitmap management.

If all IDs from trypid to pid_max were used as pids, the code would enter
a loop which would be infinite if none of the IDs could become free (e.g.
they all belong to processes which did not transitioned to zombie).

Fixes:	r341684 ("Manage process-related IDs with bitmaps")

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Mateusz Guzik 2018-12-08 10:22:12 +00:00
parent e52327e3c5
commit eab2132ad9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=341723

View File

@ -273,8 +273,10 @@ fork_findpid(int flags)
}
bit_ffc_at(&proc_id_pidmap, trypid, pid_max, &result);
if (result == -1)
if (result == -1) {
trypid = 100;
goto retry;
}
if (bit_test(&proc_id_grpidmap, result) ||
bit_test(&proc_id_sessidmap, result) ||
bit_test(&proc_id_reapmap, result)) {