Avoid race condition with Popen.send_signal

Heiko Wundram modelnine at modelnine.org
Tue Jan 3 07:31:55 EST 2012


Am 03.01.2012 02:19, schrieb Adam Skutt:
> On Jan 2, 6:09 pm, Jérôme<jer... at jolimont.fr>  wrote:
>> What is the clean way to avoid this race condition ?
>
> The fundamental race condition cannot be removed nor avoided. Ideally,
> avoid the need to send the subprocess a signal in the first place.  If
> it cannot be avoided, then trap the exception.

Yes, it can be avoided, that's what the default SIGCHLD-handling 
(keeping the process as a zombie until it's explicitly collected by a 
wait*()) is for, which forces the PID not to be reused by the operating 
system until the parent has acknowledged (by actively calling wait*()) 
that the child has terminated.

-- 
--- Heiko.



More information about the Python-list mailing list