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


Groups > comp.lang.python > #13058

Re: killing a script

From Nobody <nobody@nowhere.com>
Subject Re: killing a script
Date 2011-09-10 10:47 +0100
Message-Id <pan.2011.09.10.09.47.28.932000@nowhere.com>
Newsgroups comp.lang.python
References <4e6a0382$0$29982$c3e8da3$5496439d@news.astraweb.com> <mailman.917.1315607348.27778.python-list@python.org> <4e6abc95$0$29995$c3e8da3$5496439d@news.astraweb.com>
Organization Zen Internet

Show all headers | View raw


On Sat, 10 Sep 2011 11:25:40 +1000, Steven D'Aprano wrote:

>> and sure enough, "man 3 system" says:
> 
> I don't consider having to look up documentation for a function in a
> completely different language (in this case, C) as "documented behaviour of
> os.system". 

Well, tough luck. os.system() is a wrapper around the platform's system().
The authors of the Python documentation cannot possibly know what that
function will do on all platforms, even less so once you factor in the
user's ability to replace that function via platform-specific means.

> Does the C standard define the behaviour of system(), or is that
> implementation dependent?

The C99 standard says:

       7.20.4.5  The system function

       Synopsis

       [#1]

               #include <stdlib.h>
               int system(const char *string);

       Description

       [#2] If string  is  a  null  pointer,  the  system  function
       determines  whether  the  host  environment  has  a  command
       processor. If string is  not  a  null  pointer,  the  system
       function  passes  the  string  pointed  to by string to that
       command processor to be  executed  in  a  manner  which  the
       implementation  shall  document;  this  might then cause the
       program calling system to behave in a non-conforming  manner
       or to terminate.

       Returns

       [#3]  If the argument is a null pointer, the system function
       returns nonzero only if a command  processor  is  available.
       If  the  argument  is  not  a  null  pointer, and the system
       function does return, it returns  an  implementation-defined
       value.

It doesn't require a platform to even have a command interpreter, let
alone specify its behaviour. On Unix, system() is defined to use /bin/sh,
which ought to be some kind of Bourne shell; but even then, it might be a
minimal shell such as dash or something with many extensions such as bash.
On Windows, it uses the interpreter specified by the COMSPEC environment
variable, or cmd.exe (NT-based) or command.com (DOS-based) if COMSPEC
isn't set (in either case, PATH is used).

> It sounds to me that the Python developers are
> implicitly refusing responsibility for the detailed behaviour of os.system
> by noting that it depends on the C function.

Indeed. Which is the correct thing to do. Practically every function in
the os module does likewise.

> What do Jython, PyPy and IronPython do?
 
I don't know, but I would expect them to use libc's system() function,
except for Jython which might use java.lang.Runtime.exec().

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