# HG changeset patch # Parent 50bfb0899095c22d9fa5b74d681889cefc59f250 diff -r 50bfb0899095 -r 08b1df2f3a21 Doc/library/os.rst --- a/Doc/library/os.rst Sun Jun 21 10:47:20 2015 -0700 +++ b/Doc/library/os.rst Mon Jun 22 06:29:01 2015 +0000 @@ -3180,12 +3180,12 @@ the Standard C function :c:func:`system`, and has the same limitations. Changes to :data:`sys.stdin`, etc. are not reflected in the environment of the executed command. If *command* generates any output, it will be sent to - the interpreter standard output stream. + the interpreter standard output stream. The C standard does not + specify the meaning of the return value of C function, so the return + value of the Python function is system-dependent. On Unix, the return value is the exit status of the process encoded in the - format specified for :func:`wait`. Note that POSIX does not specify the - meaning of the return value of the C :c:func:`system` function, so the return - value of the Python function is system-dependent. + format specified for :func:`wait`. On Windows, the return value is that returned by the system shell after running *command*. The shell is given by the Windows environment variable diff -r 50bfb0899095 -r 08b1df2f3a21 Doc/library/subprocess.rst --- a/Doc/library/subprocess.rst Sun Jun 21 10:47:20 2015 -0700 +++ b/Doc/library/subprocess.rst Mon Jun 22 06:29:01 2015 +0000 @@ -825,7 +825,7 @@ .. function:: call(args, *, stdin=None, stdout=None, stderr=None, shell=False, timeout=None) Run the command described by *args*. Wait for command to complete, then - return the :attr:`returncode` attribute. + return the :attr:`~Popen.returncode` attribute. This is equivalent to:: @@ -956,7 +956,7 @@ output=`dmesg | grep hda` # becomes - output=check_output("dmesg | grep hda", shell=True) + output = check_output("dmesg | grep hda", shell=True) Replacing :func:`os.system` @@ -966,12 +966,19 @@ sts = os.system("mycmd" + " myarg") # becomes - sts = call("mycmd" + " myarg", shell=True) + retcode = call("mycmd" + " myarg", shell=True) Notes: * Calling the program through the shell is usually not required. +* The :func:`call` return value is encoded differently to that of + :func:`os.system`. + +* The :func:`os.system` function ignores SIGINT and SIGQUIT signals while + the command is running, but the caller must do this separately when + using the :mod:`subprocess` module. + A more realistic example would look like this:: try: