Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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; 'bug.': 0.07; 'whichever': 0.07; 'python': 0.08; 'bash': 0.09; 'from:addr:python': 0.09; 'scripts,': 0.09; 'top-level': 0.09; 'wrong,': 0.09; 'case.': 0.15; '"lucky"': 0.16; 'control-c': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'occasionally': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'repeatedly,': 0.16; 'reply-to:addr :python-list': 0.16; 'russ': 0.16; 'wrote:': 0.16; 'linux': 0.17; 'header:In-Reply-To:1': 0.22; 'stack': 0.24; 'keeps': 0.26; 'thanks.': 0.26; 'received:84': 0.28; 'exit': 0.29; 'script.': 0.29; 'fix': 0.29; 'script': 0.29; 'does': 0.32; 'there': 0.33; 'to:addr:python-list': 0.33; 'that,': 0.33; 'however,': 0.34; 'header:User-Agent:1': 0.34; 'reply-to:addr:python.org': 0.34; 'running': 0.35; 'several': 0.37; 'something': 0.37; 'could': 0.38; 'subject:: ': 0.39; 'goes': 0.39; 'to:addr:python.org': 0.39; 'hit': 0.40; 'happens': 0.40; 'processing': 0.40; 'header :Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.71; 'darn': 0.84; 'kills': 0.84 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMGAGDwWk5UXebj/2dsb2JhbABCmF2PGneBQAEBBThAEQsIEAkUAg8JAwIBAgENOBMIAQGHcLclhkwEi2RJjACLdw Date: Mon, 29 Aug 2011 02:52:22 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0) Gecko/20110812 Thunderbird/6.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: killing a script References: <22a0dae6-8a60-4e68-82a5-31a949bd69d5@y8g2000prd.googlegroups.com> In-Reply-To: <22a0dae6-8a60-4e68-82a5-31a949bd69d5@y8g2000prd.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: python-list@python.org 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1314582745 news.xs4all.nl 2502 [2001:888:2000:d::a6]:52070 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:12373 On 29/08/2011 02:15, Russ P. wrote: > I have a Python (2.6.x) script on Linux that loops through many > directories and does processing for each. That processing includes > several "os.system" calls for each directory (some to other Python > scripts, others to bash scripts). > > Occasionally something goes wrong, and the top-level script just keeps > running with a stack dump for each case. When I see that, I want to > just kill the whole thing and fix the bug. However, when I hit Control- > C, it apparently just just kills whichever script happens to be > running at that instant, and the top level script just moves to the > next line and keeps running. If I hit Control-C repeatedly, I > eventually get "lucky" and kill the top-level script. Is there a > simple way to ensure that the first Control-C will kill the whole darn > thing, i.e, the top-level script? Thanks. > You could look at the return value of os.system, which may tell you the exit status of the process.