Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.news-service.com!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!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; '2.7': 0.04; 'encoded': 0.05; 'chooses': 0.07; 'interpreter': 0.07; 'received:edu.au': 0.07; 'see:': 0.07; 'stuff,': 0.07; 'python': 0.08; 'invocation': 0.09; 'mentions': 0.09; 'subprocess': 0.09; 'unix,': 0.09; 'blocking': 0.13; 'debugging': 0.13; 'argument': 0.15; 'ctrl-c': 0.16; 'docstring': 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; '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; 'repeatedly,': 0.16; 'where?': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.16; 'continuing': 0.17; 'cheers,': 0.18; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'documented': 0.23; 'incorrect': 0.23; 'command': 0.24; 'receives': 0.24; 'shell': 0.24; 'ignore': 0.26; '"the': 0.26; 'function': 0.27; 'exit': 0.29; 'cc:addr:python.org': 0.30; 'not.': 0.30; 'specified': 0.31; 'url:library': 0.31; 'does': 0.32; 'app': 0.33; 'it.': 0.33; 'calling': 0.33; 'header:User- Agent:1': 0.34; 'all.': 0.34; 'anything': 0.36; 'charset:us- ascii': 0.36; 'url:python': 0.36; 'received:au': 0.36; 'convenient': 0.37; 'executing': 0.37; 'but': 0.37; 'mike': 0.38; 'steven': 0.38; 'url:org': 0.38; 'easier': 0.38; 'subject:: ': 0.39; 'correctly': 0.39; 'url:docs': 0.39; 'hit': 0.40; 'url:net': 0.60; 'hands': 0.64; 'received:202': 0.66; 'making': 0.67; 'cameron': 0.67; 'receive': 0.67; '*does*': 0.84; 'limitations.': 0.84; 'running,': 0.84; 'url:os': 0.84; 'died': 0.97 Date: Sat, 10 Sep 2011 08:29:02 +1000 From: Cameron Simpson To: Steven D'Aprano Subject: Re: killing a script MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4e6a0382$0$29982$c3e8da3$5496439d@news.astraweb.com> User-Agent: Mutt/1.5.21 (2010-09-15) References: <4e6a0382$0$29982$c3e8da3$5496439d@news.astraweb.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: 47 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1315607348 news.xs4all.nl 2544 [2001:888:2000:d::a6]:46698 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:13037 On 09Sep2011 22:16, Steven D'Aprano wrote: | Hans Mulder wrote: | > On 9/09/11 11:07:24, Steven D'Aprano wrote: | >> Sure enough, I now have to hit Ctrl-C repeatedly, once per invocation of | >> script.py. While script.py is running, it receives the Ctrl-C, the | >> calling process does not. | > | > You misinterpret what you are seeing: the calling process *does* receive | > the ctrl-C, it just chooses to ignore it. | > | > This is documented behaviour of os.system. | | Documented where? Neither the on-line documentation nor the function | docstring mentions anything about it that I can see: | | http://docs.python.org/py3k/library/os.html#os.system My copy of the 2.7 docs says: This is implemented by calling the Standard C function system(), and has the same limitations. and sure enough, "man 3 system" says: The system() function hands the argument command to the command interpreter sh(1). The calling process waits for the shell to finish executing the command, ignoring SIGINT and SIGQUIT, and blocking SIGCHLD. os.system() is very convenient for simple stuff, but one size does not fit all. Continuing with the Python docs for os.system: On Unix, the return value is the exit status of the process encoded in the format specified for wait(). and it is easy to inspect that value for "the subprocess died from a signal". Not inspecting the exit status correctly will always be an opportunity for incorrect app behaviour. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Mac OS X. Because making Unix user-friendly is easier than debugging Windows. - Mike Dawson, Macintosh Systems Administrator and Consultation. mdawson@mac.com http://herowars.onestop.net