Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #13037

Re: killing a script

Date 2011-09-10 08:29 +1000
From Cameron Simpson <cs@zip.com.au>
Subject Re: killing a script
References <4e6a0382$0$29982$c3e8da3$5496439d@news.astraweb.com>
Newsgroups comp.lang.python
Message-ID <mailman.917.1315607348.27778.python-list@python.org> (permalink)

Show all headers | View raw


On 09Sep2011 22:16, Steven D'Aprano <steve+comp.lang.python@pearwood.info> 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 <cs@zip.com.au> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

killing a script "Russ P." <russ.paielli@gmail.com> - 2011-08-28 18:15 -0700
  Re: killing a script MRAB <python@mrabarnett.plus.com> - 2011-08-29 02:52 +0100
    Re: killing a script "Russ P." <russ.paielli@gmail.com> - 2011-08-28 19:41 -0700
      Re: killing a script Chris Angelico <rosuav@gmail.com> - 2011-08-29 12:51 +1000
        Re: killing a script "Russ P." <russ.paielli@gmail.com> - 2011-08-28 20:08 -0700
          Re: killing a script Chris Rebert <clp2@rebertia.com> - 2011-08-28 20:16 -0700
            Re: killing a script "Russ P." <russ.paielli@gmail.com> - 2011-08-28 20:22 -0700
            Re: killing a script "Russ P." <russ.paielli@gmail.com> - 2011-08-29 14:26 -0700
          Re: killing a script Thomas Jollans <t@jollybox.de> - 2011-08-29 09:49 +0200
          Re: killing a script Arnaud Delobelle <arnodel@gmail.com> - 2011-08-29 23:53 +0100
            Re: killing a script Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-30 14:13 +1000
              Re: killing a script Hans Mulder <hansmu@xs4all.nl> - 2011-08-30 12:40 +0200
              Re: killing a script Cameron Simpson <cs@zip.com.au> - 2011-09-09 10:03 +1000
                Re: killing a script Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-09 19:07 +1000
                Re: killing a script Hans Mulder <hansmu@xs4all.nl> - 2011-09-09 12:13 +0200
                Re: killing a script Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-09 22:16 +1000
                Re: killing a script Cameron Simpson <cs@zip.com.au> - 2011-09-10 08:29 +1000
                Re: killing a script Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-10 11:25 +1000
                Re: killing a script Chris Angelico <rosuav@gmail.com> - 2011-09-10 11:37 +1000
                Re: killing a script Cameron Simpson <cs@zip.com.au> - 2011-09-10 18:49 +1000
                Re: killing a script Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-11 15:08 +1000
                Re: killing a script Nobody <nobody@nowhere.com> - 2011-09-10 10:47 +0100
      Re: killing a script Paul Rubin <no.email@nospam.invalid> - 2011-08-28 19:53 -0700
  Re: killing a script Nobody <nobody@nowhere.com> - 2011-08-29 07:52 +0100

csiph-web