Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'wed,': 0.04; 'behave': 0.07; 'fine,': 0.07; 'terry': 0.07; 'python': 0.07; 'fatal': 0.09; 'nicely': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'signals': 0.09; 'pm,': 0.11; 'output': 0.12; 'binary': 0.14; 'wrote:': 0.14; 'ever.': 0.16; 'hangs': 0.16; 'reedy': 0.16; 'subject:skip:s 10': 0.16; 'tend': 0.16; 'traceback': 0.16; 'tries': 0.16; 'jan': 0.22; 'header:In-Reply-To:1': 0.22; '(and': 0.22; 'skip:` 20': 0.23; 'script': 0.26; "doesn't": 0.28; 'error': 0.29; 'nobody': 0.29; 'third-party': 0.29; 'to:addr:python-list': 0.32; 'module': 0.33; 'header:X-Complaints-To:1': 0.34; 'question': 0.35; 'header:User- Agent:1': 0.35; '-0700,': 0.35; 'error.': 0.36; 'case,': 0.36; 'run': 0.37; 'apr': 0.38; 'received:org': 0.38; 'help': 0.39; 'returning': 0.39; 'to:addr:python.org': 0.39; 'header:Mime- Version:1': 0.39; 'except': 0.39; 'works': 0.40; 'header:Received:5': 0.40; 'retrieve': 0.60; '2011': 0.62; '3.3': 0.84; 'victor': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Trapping the segfault of a subprocess.Popen Date: Wed, 06 Apr 2011 23:12:40 -0400 References: <5adc9111-e7a5-4486-9809-f6a74f96a965@i14g2000yqe.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: rain.gmane.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9 In-Reply-To: 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: 20 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1302145972 news.xs4all.nl 41102 [::ffff:82.94.164.166]:45787 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:2738 On 4/6/2011 7:58 PM, Nobody wrote: > On Wed, 06 Apr 2011 02:20:22 -0700, Pierre GM wrote: > >> I need to run a third-party binary from a python script and retrieve >> its output (and its error messages). I use something like >>>>> process = subprocess.Popen(options, stdout=subprocess.PIPE, >> stderr=subprocess.PIPE) >>>>> (info_out, info_err) = process.communicate() >> That works fine, except that the third-party binary in question doesn't >> behave very nicely and tend to segfaults without returning any error. In >> that case, `process.communicate` hangs for ever. I am not sure this will help you now, but.... Victor Stinner has added a new module to Python 3.3 that tries to catch segfaults and other fatal signals and produce a traceback before Python disappears. -- Terry Jan Reedy