bpo-20104: Add os.posix_spawn documentation. (GH-6334) · python/cpython@ab84572 (original) (raw)

Original file line number Diff line number Diff line change
@@ -3353,6 +3353,31 @@ written in Python, such as a mail server's external command delivery program.
3353 3353 subprocesses.
3354 3354
3355 3355
3356 +.. function:: posix_spawn(path, argv, env, file_actions=None)
3357 +
3358 + Wraps the posix_spawn() C library API for use from Python.
3359 +
3360 + Most users should use :class:`subprocess.run` instead of posix_spawn.
3361 +
3362 + The *path*, *args*, and *env* arguments are similar to :func:`execve`.
3363 +
3364 + The *file_actions* argument may be a sequence of tuples describing actions
3365 + to take on specific file descriptors in the child process between the C
3366 + library implementation's fork and exec steps. The first item in each tuple
3367 + must be one of the three type indicator listed below describing the
3368 + remaining tuple elements:
3369 +
3370 + (os.POSIX_SPAWN_OPEN, fd, path, open flags, mode)
3371 + (os.POSIX_SPAWN_CLOSE, fd)
3372 + (os.POSIX_SPAWN_DUP2, fd, new_fd)
3373 +
3374 + These tuples correspond to the C library posix_spawn_file_actions_addopen,
3375 + posix_spawn_file_actions_addclose, and posix_spawn_file_actions_adddup2 API
3376 + calls used to prepare for the posix_spawn call itself.
3377 +
3378 + .. versionadded:: 3.7
3379 +
3380 +
3356 3381 .. function:: register_at_fork(*, before=None, after_in_parent=None, \
3357 3382 after_in_child=None)
3358 3383