Process — Child process spawning handle¶
Process handles allow spawning child processes which can be controlled (their stdin and
Pipe handles within an event loop.
Disables inheritance for file descriptors / handles that this process inherited from its parent. The effect is that child processes spawned by this process don’t accidentally inherit these handles.
It is recommended to call this function as early in your program as possible, before the inherited file descriptors can be closed or duplicated.
Note that this function works on a best-effort basis: there is no guarantee that libuv can discover all file descriptors that were inherited. In general it does a better job on Windows than it does on unix.
spawn(loop, args[, executable[, env[, cwd[, uid[, gid[, flags[, stdio[, exit_callback]]]]]]]])¶
Loop loop: pyuv.Loop instance where this handle belongs.
- args (list) – Arguments for the new process. In case it’s just the executable, it’s possible to specify it as a string instead of a single element list.
- executable (string) – File to be executed. args is taken in case it’s not specified.
- exit_callback (callable) – Callback to be called when the process exits.
- env (dict) – Overrides the environment for the child process. If none is specified the one from the parent is used.
- cwd (string) – Specifies the working directory where the child process will be executed.
- uid (int) – UID of the user to be used if flag
- gid (int) – GID of the group to be used if flag
- flags (int) –
UV_PROCESS_SETUID: set child UID
UV_PROCESS_SETGID: set child GID
UV_PROCESS_WINDOWS_HIDE: hide the subprocess console window that would normally be created. This option is only meaningful on Windows systems. On unix it is silently ignored.
UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS: pass arguments verbatim, that is, not enclosed in double quotes (Windows)
UV_PROCESS_DETACHED: detach child process from parent
- stdio (list) – Sequence containing
StdIOcontainers which will be used to pass stdio handles to the child process. See the
StdIOclass documentation for for information.
Spawn the specified child process.
Exit callback signature:
callback(process_handle, exit_status, term_signal).
Parameters: signal (int) – Signal to be sent to the process.
Send the specified signal to the child process.
PID of the spawned process.
StdIO([[[stream], fd], flags])¶
- stream (object) – Stream object.
- fd (int) – File descriptor.
- flags (int) – Flags.
Create a new container for passing stdio to a child process. Stream can be any stream object, that is
TTY. An arbitrary file descriptor can be passed by setting the
The operation mode is selected by setting the
- UV_IGNORE: this container should be ignored.
- UV_CREATE_PIPE: indicates a pipe should be created. UV_READABLE_PIPE and UV_WRITABLE_PIPE determine the direction of flow, from the child process’ perspective. Both flags may be specified to create a duplex data stream.
- UV_INHERIT_FD: inherit the given file descriptor in the child.
- UV_INHERIT_STREAM: inherit the file descriptor of the given stream in the child.