10000 [3.9] bpo-23750: Document os-system, subprocess. Patch by Martin Panter. (GH-26016) by miss-islington · Pull Request #26041 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.9] bpo-23750: Document os-system, subprocess. Patch by Martin Panter. (GH-26016) #26041

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3965,12 +3965,12 @@ written in Python, such as a mail server's external command delivery program.
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 the 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
Expand Down
8 changes: 7 additions & 1 deletion Doc/library/subprocess.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1268,11 +1268,17 @@ Replacing :func:`os.system`

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::

Expand Down
0