Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.033 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'exception.': 0.09; 'subprocess': 0.09; 'adam': 0.16; 'ideally,': 0.16; 'received:10.2': 0.16; 'terminated.': 0.16; 'trap': 0.16; 'wrote:': 0.18; 'jan': 0.19; 'header:In-Reply-To:1': 0.22; 'explicitly': 0.29; 'pm,': 0.29; 'for,': 0.30; 'parent': 0.30; '---': 0.31; 'header:User-Agent:1': 0.33; 'to:addr:python-list': 0.34; 'calling': 0.34; 'forces': 0.34; 'fundamental': 0.34; 'operating': 0.35; 'actively': 0.36; 'subject:with': 0.36; '(by': 0.37; 'signal': 0.38; 'received:org': 0.38; "it's": 0.40; 'to:addr:python.org': 0.40; 'race': 0.77; 'avoided.': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=modelnine.org; s=modelnine1012; t=1325593921; bh=6mGiwFsXnvJQwhwIe/VCVxNeBVygS6suajAjFu6MdF0=; h=Message-ID:Date:From:MIME-Version:To:Subject:References: In-Reply-To:Content-Type:Content-Transfer-Encoding; b=TTdfwtL75qjd/t7O5sYlEASRpaI5OhU4joDV/utbhZWRR6YFJ5/wjuKVmmiFYbELL cawxIahuxnEPy7wp52xqkChWGMebasy4PGCYV+SrBiokOf9ZbABlekFwg1WQpA8IoI 8XFLxqmVjiLnUXWBXmUY/WPHPV9eicQU8vNoUUBI= Date: Tue, 03 Jan 2012 13:31:55 +0100 From: Heiko Wundram User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0) Gecko/20111222 Thunderbird/10.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Avoid race condition with Popen.send_signal References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1325593922 news.xs4all.nl 6881 [2001:888:2000:d::a6]:45237 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:18398 Am 03.01.2012 02:19, schrieb Adam Skutt: > On Jan 2, 6:09 pm, Jérôme 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.