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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'sure.': 0.05; 'indeed,': 0.07; 'received:edu.au': 0.07; 'variant': 0.07; 'silently': 0.09; 'exception': 0.12; 'case.': 0.15; 'adam': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'nail': 0.16; 'place:': 0.16; 'posix': 0.16; 'pythonic': 0.16; 'received:202.125.174': 0.16; 'received:202.125.174.133': 0.16; 'received:boardofstudies.nsw.edu.au': 0.16; 'received:cskk.homeip.net': 0.16; 'received:harvey.boardofstudies.nsw.edu.au': 0.16; 'received:homeip.net': 0.16; 'received:nsw.edu.au': 0.16; 'rogue': 0.16; 'stderr': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'jan': 0.19; 'possibly': 0.19; 'cc:no real name:2**0': 0.20; 'cheers,': 0.20; 'linux,': 0.21; 'header:In-Reply-To:1': 0.22; 'interpreted': 0.23; 'precise': 0.23; 'unlikely': 0.23; 'cc:2**0': 0.24; '"the': 0.26; 'pass': 0.29; 'cc:addr:python.org': 0.29; 'error': 0.29; 'correct': 0.29; 'also.': 0.30; 'line:': 0.30; 'least': 0.30; 'pretty': 0.32; 'header:User-Agent:1': 0.33; 'probably': 0.34; 'anything': 0.34; 'symbol': 0.34; 'issue': 0.35; 'received:au': 0.36; 'subject:with': 0.36; 'fair': 0.37; 'but': 0.37; 'run': 0.37; 'think': 0.37; 'skip:_ 10': 0.37; 'enough': 0.38; 'signal': 0.38; 'returned': 0.39; 'possible.': 0.39; 'should': 0.39; 'being': 0.39; 'why': 0.39; "it's": 0.40; 'more': 0.61; 'your': 0.61; 'received:202': 0.66; 'taking': 0.66; 'risk': 0.71; 'cameron': 0.73; 'death': 0.80; 'chek': 0.84; "life's": 0.84; 'mandates': 0.84; 'killing': 0.91; 'innocent': 0.93 Date: Tue, 3 Jan 2012 15:53:07 +1100 From: Cameron Simpson To: Adam Skutt Subject: Re: Avoid race condition with Popen.send_signal MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <63817f2b-ccf8-4d7d-92a6-c1d622986d8a@j10g2000vbe.googlegroups.com> User-Agent: Mutt/1.5.21 (2010-09-15) References: <63817f2b-ccf8-4d7d-92a6-c1d622986d8a@j10g2000vbe.googlegroups.com> Cc: python-list@python.org 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: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1325566392 news.xs4all.nl 6874 [2001:888:2000:d::a6]:44751 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:18370 On 02Jan2012 19:16, Adam Skutt wrote: | On Jan 2, 8:44 pm, Cameron Simpson wrote: | > On 02Jan2012 20:31, Devin Jeanpierre wrote: | > | > I think that catching the exception is probably the most Pythonic way. | > | | > | It's the only correct way. | > | > Indeed, but be precise - chek that it _is_ error 3, or more portably, | > errno.ESRCH. POSIX probably mandates that that is a 3, but the symbol | > should track the local system if it differs. Example: | | No. It is possible (however unlikely) for EPERM to be legitimately | returned in this case. Anything other than EINVAL should be | interpreted as "The child process is dead". Sure. I was more taking the line: catch and accept only the specific errors you understand. Of course he can catch EPERM also. But any other variant should at the least generate a warning to stderr or a log - it is _unexpected_. I take your point that reraising the exception may be overkill for failed signal delivery (if that was your point). But I am arguing for being very careful about what you silently pass as an ok thing. | Hence why you should | avoid sending the signal in the first place: the situations where you | don't run the risk of possibly killing an innocent bystander are | pretty narrow. While unlikely on modern UNiX and Linux, IMO it's best | to avoid the issue altogether whenever possible. Fair enough too. But sometimes you need to nail a rogue child. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Death is life's way of telling you you've been fired. - R. Geis