ProcessReaper: single thread reaper

Peter Levart peter.levart at gmail.com
Tue Apr 15 05:50:06 UTC 2014


On 04/15/2014 12:04 AM, David M. Lloyd wrote:
>> There's already such a race in current implementation of
>> Process.terminate(). It admittedly only concerns a small window between
>> process exiting and the reaper thread managing to signal this state to
>> the other threads wishing to terminate it at the same time, so it could
>> happen that a KILL/TERM signal is sent to an already deceased PID which
>> was re-used, but it doesn't happen in practice since PIDs are not
>> re-used very soon typically.
>
> It seems like it would be trivial enough to introduce a 
> synchronization between the reaper thread and whatever API signals 
> child processes. 

Not really. Reaper thread(s) wait in system call (waitpid()), so holding 
a mutex while waiting would prevent other threads from killing the 
process. After the call returns, the PID is already released and could 
theoretically be re-used. But in practice this is really not a problem.


Regards, Peter




More information about the core-libs-dev mailing list