Skip to content

Commit a3947a4

Browse files
committed
gh-126931: Clarify arguments to os.spawn functions
1 parent 31ed3ef commit a3947a4

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

‎Doc/library/os.rst‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5516,10 +5516,10 @@ written in Python, such as a mail server's external command delivery program.
55165516
.. versionadded:: 3.7
55175517

55185518

5519-
.. function:: spawnl(mode, file, ...)
5520-
spawnle(mode, file, ..., env)
5521-
spawnlp(mode, file, ...)
5522-
spawnlpe(mode, file, ..., env)
5519+
.. function:: spawnl(mode, file, arg0, ...)
5520+
spawnle(mode, file, arg0, ..., env)
5521+
spawnlp(mode, file, arg0, ...)
5522+
spawnlpe(mode, file, arg0, ..., env)
55235523
spawnv(mode, file, args)
55245524
spawnve(mode, file, args, env)
55255525
spawnvp(mode, file, args)
@@ -5541,14 +5541,13 @@ written in Python, such as a mail server's external command delivery program.
55415541
Note on VxWorks, this function doesn't return ``-signal`` when the new process is
55425542
killed. Instead it raises OSError exception.
55435543

5544-
The "l" and "v" variants of the :func:`spawn\* <spawnl>` functions differ in how
5545-
command-line arguments are passed. The "l" variants are perhaps the easiest
5546-
to work with if the number of parameters is fixed when the code is written; the
5547-
individual parameters simply become additional parameters to the
5548-
:func:`!spawnl\*` functions. The "v" variants are good when the number of
5549-
parameters is variable, with the arguments being passed in a list or tuple as
5550-
the *args* parameter. In either case, the arguments to the child process must
5551-
start with the name of the command being run.
5544+
The "l" variants take each command-line argument as a separate positional
5545+
argument, starting with *arg0*. The "v" variants take the arguments as a list
5546+
or tuple in *args*. In both cases, the first command-line argument becomes
5547+
the child process's ``argv[0]`` and must be non-empty. By convention, it is
5548+
the name of the program being run. If the program needs no arguments after
5549+
``argv[0]``, use ``spawnl(mode, file, program_name)`` or
5550+
``spawnv(mode, file, [program_name])``.
55525551

55535552
The variants which include a second "p" near the end (:func:`spawnlp`,
55545553
:func:`spawnlpe`, :func:`spawnvp`, and :func:`spawnvpe`) will use the

0 commit comments

Comments
 (0)