Skip to content

Commit 6fc6f43

Browse files
bpo-23750: Document os-system, subprocess. Patch by Martin Panter. (GH-26016) (GH-26040)
* Document os-system, subprocess Patch * Update Doc/library/os.rst Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> (cherry picked from commit 5f2eb87) Co-authored-by: uniocto <serit142sa33go@gmail.com> Co-authored-by: uniocto <serit142sa33go@gmail.com>
1 parent 7bef7a1 commit 6fc6f43

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Doc/library/os.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4211,12 +4211,12 @@ written in Python, such as a mail server's external command delivery program.
42114211
the Standard C function :c:func:`system`, and has the same limitations.
42124212
Changes to :data:`sys.stdin`, etc. are not reflected in the environment of
42134213
the executed command. If *command* generates any output, it will be sent to
4214-
the interpreter standard output stream.
4214+
the interpreter standard output stream. The C standard does not
4215+
specify the meaning of the return value of the C function, so the return
4216+
value of the Python function is system-dependent.
42154217

42164218
On Unix, the return value is the exit status of the process encoded in the
4217-
format specified for :func:`wait`. Note that POSIX does not specify the
4218-
meaning of the return value of the C :c:func:`system` function, so the return
4219-
value of the Python function is system-dependent.
4219+
format specified for :func:`wait`.
42204220

42214221
On Windows, the return value is that returned by the system shell after
42224222
running *command*. The shell is given by the Windows environment variable

Doc/library/subprocess.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1292,11 +1292,17 @@ Replacing :func:`os.system`
12921292

12931293
sts = os.system("mycmd" + " myarg")
12941294
# becomes
1295-
sts = call("mycmd" + " myarg", shell=True)
1295+
retcode = call("mycmd" + " myarg", shell=True)
12961296

12971297
Notes:
12981298

12991299
* Calling the program through the shell is usually not required.
1300+
* The :func:`call` return value is encoded differently to that of
1301+
:func:`os.system`.
1302+
1303+
* The :func:`os.system` function ignores SIGINT and SIGQUIT signals while
1304+
the command is running, but the caller must do this separately when
1305+
using the :mod:`subprocess` module.
13001306

13011307
A more realistic example would look like this::
13021308

0 commit comments

Comments
 (0)