Skip to content
Open
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
4 changes: 2 additions & 2 deletions deps/uv/docs/src/pipe.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ API
Create a pair of connected pipe handles.
Data may be written to `fds[1]` and read from `fds[0]`.
The resulting handles can be passed to `uv_pipe_open`, used with `uv_spawn`,
or for any other purpose.
The resulting handles can be passed to `uv_pipe_open`, used with
`uv_spawn` / `uv_spawn2` or for any other purpose.
Valid values for `flags` are:
Expand Down
100 changes: 86 additions & 14 deletions deps/uv/docs/src/process.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Data types

.. c:type:: uv_process_options_t

Deprecated, use `uv_spawn2` with `uv_process_options2_t` instead.

Options for spawning the process (passed to :c:func:`uv_spawn`.

::
Expand All @@ -34,15 +36,37 @@ Data types
uv_gid_t gid;
} uv_process_options_t;

.. c:type:: uv_process_options2_t

Options for spawning the process (passed to :c:func:`uv_spawn2`.

::

typedef struct uv_process_options2_s {
int version;
uv_exit_cb exit_cb;
const char* file;
char** args;
char** env;
const char* cwd;
unsigned int flags;
int stdio_count;
uv_stdio_container_t* stdio;
unsigned int pty_cols;
unsigned int pty_rows;
uv_uid_t uid;
uv_gid_t gid;
} uv_process_options2_t;

.. c:type:: void (*uv_exit_cb)(uv_process_t*, int64_t exit_status, int term_signal)

Type definition for callback passed in :c:type:`uv_process_options_t` which
Type definition for callback passed in :c:type:`uv_process_options2_t` which
will indicate the exit status and the signal that caused the process to
terminate, if any.

.. c:enum:: uv_process_flags

Flags to be set on the flags field of :c:type:`uv_process_options_t`.
Flags to be set on the flags field of :c:type:`uv_process_options2_t`.

::

Expand Down Expand Up @@ -88,11 +112,20 @@ Data types
UV_PROCESS_WINDOWS_HIDE_GUI = (1 << 6),
/*
* On Windows, if the path to the program to execute, specified in
* uv_process_options_t's file field, has a directory component,
* uv_process_options2_t's file field, has a directory component,
* search for the exact file name before trying variants with
* extensions like '.exe' or '.cmd'.
*/
UV_PROCESS_WINDOWS_FILE_PATH_EXACT_NAME = (1 << 7)
UV_PROCESS_WINDOWS_FILE_PATH_EXACT_NAME = (1 << 7),
/*
* Start subprocess with a pseudo terminal. To use this flag, set
* stdio[0] to UV_CREATE_PIPE | UV_READABLE_PIPE and
* stdio[1] to UV_CREATE_PIPE | UV_WRITABLE_PIPE and
* stdio[2] to UV_IGNORE. The first pipe will be the PTY in (write here),
* while the second pipe will be the PTY out (read here). The child will have
* all standard FDs (0, 1 and 2) connected to the PTY as it should.
*/
UV_PROCESS_PTY = (1 << 8)
};

.. c:type:: uv_stdio_container_t
Expand Down Expand Up @@ -177,36 +210,40 @@ Public members
.. note::
The :c:type:`uv_handle_t` members also apply.

.. c:member:: uv_exit_cb uv_process_options_t.exit_cb
.. c:member:: uv_exit_cb uv_process_options2_t.version

Version of the struct. Simply set it to UV_PROCESS_OPTIONS_VERSION.

.. c:member:: uv_exit_cb uv_process_options2_t.exit_cb

Callback called after the process exits.

.. c:member:: const char* uv_process_options_t.file
.. c:member:: const char* uv_process_options2_t.file

Path pointing to the program to be executed.

.. c:member:: char** uv_process_options_t.args
.. c:member:: char** uv_process_options2_t.args

Command line arguments. args[0] should be the path to the program. On
Windows this uses `CreateProcess` which concatenates the arguments into a
string this can cause some strange errors. See the
``UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS`` flag on :c:enum:`uv_process_flags`.

.. c:member:: char** uv_process_options_t.env
.. c:member:: char** uv_process_options2_t.env

Environment for the new process. If NULL the parents environment is used.

.. c:member:: const char* uv_process_options_t.cwd
.. c:member:: const char* uv_process_options2_t.cwd

Current working directory for the subprocess.

.. c:member:: unsigned int uv_process_options_t.flags
.. c:member:: unsigned int uv_process_options2_t.flags

Various flags that control how :c:func:`uv_spawn` behaves. See
:c:enum:`uv_process_flags`.

.. c:member:: int uv_process_options_t.stdio_count
.. c:member:: uv_stdio_container_t* uv_process_options_t.stdio
.. c:member:: int uv_process_options2_t.stdio_count
.. c:member:: uv_stdio_container_t* uv_process_options2_t.stdio

The `stdio` field points to an array of :c:type:`uv_stdio_container_t`
structs that describe the file descriptors that will be made available to
Expand All @@ -217,8 +254,14 @@ Public members
On Windows file descriptors greater than 2 are available to the child process only if
the child processes uses the MSVCRT runtime.

.. c:member:: uv_uid_t uv_process_options_t.uid
.. c:member:: uv_gid_t uv_process_options_t.gid
.. c:member:: uv_gid_t uv_process_options2_t.pty_cols
.. c:member:: uv_uid_t uv_process_options2_t.pty_rows

When installing a PTY via the `UV_PROCESS_PTY` flag, set the initial
pseudo terminal dimensions via these fields.

.. c:member:: uv_uid_t uv_process_options2_t.uid
.. c:member:: uv_gid_t uv_process_options2_t.gid

Libuv can change the child process' user/group id. This happens only when
the appropriate bits are set in the flags fields.
Expand Down Expand Up @@ -256,6 +299,9 @@ API

.. c:function:: int uv_spawn(uv_loop_t* loop, uv_process_t* handle, const uv_process_options_t* options)

Deprecated. Use `uv_spawn2`. `uv_spawn2` behaves identical, but
takes a `uv_processs_options2_t` instead.

Initializes the process handle and starts the process. If the process is
successfully spawned, this function will return 0. Otherwise, the
negative error code corresponding to the reason it couldn't spawn is
Expand All @@ -272,6 +318,24 @@ API
.. versionchanged:: 1.48.0 Added the
`UV_PROCESS_WINDOWS_FILE_PATH_EXACT_NAME` flag.

.. c:function:: int uv_spawn2(uv_loop_t* loop, uv_process_t* handle, const uv_process_options2_t* options)

Initializes the process handle and starts the process. If the process is
successfully spawned, this function will return 0. Otherwise, the
negative error code corresponding to the reason it couldn't spawn is
returned.

Possible reasons for failing to spawn would include (but not be limited to)
the file to execute not existing, not having permissions to use the setuid or
setgid specified, or not having enough memory to allocate for the new
process. If the OS does not support PTYs and `UV_PROCESS_PTY` is passed
the error will be `UV_ENOTSUP`.

.. versionadded:: 1.52.0 Identical to `uv_spawn` but takes a
`uv_process_options2_t` instead. With `uv_spawn2` it's
now possible to use a PTY via the `UV_PROCESS_PTY` flag.


.. c:function:: int uv_process_kill(uv_process_t* handle, int signum)

Sends the specified signal to the given process handle. Check the documentation
Expand All @@ -288,4 +352,12 @@ API

.. versionadded:: 1.19.0

.. c:function:: int uv_pty_resize(uv_process_t* process, unsigned short cols, unsigned short rows)

For a PTY enabled process, change the size of the terminal. Returns 0 on
success, `UV_EINVAL` when the `process` is not PTY enabled, `UV_ENOTSUP`
when the OS does not support PTYs.

.. versionadded:: 1.52.0

.. seealso:: The :c:type:`uv_handle_t` API functions also apply.
76 changes: 75 additions & 1 deletion deps/uv/include/uv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,65 @@ typedef struct uv_process_options_s {
uv_gid_t gid;
} uv_process_options_t;

#define UV_PROCESS_OPTIONS_VERSION_V0 0 /* Same as original uv_process_options_t */
#define UV_PROCESS_OPTIONS_VERSION_V1 1 /* With pty fields */

#define UV_PROCESS_OPTIONS_VERSION UV_PROCESS_OPTIONS_VERSION_V1

typedef struct uv_process_options2_s {
/* Struct version. Simply set it to UV_PROCESS_OPTIONS_VERSION. */
int version;

uv_exit_cb exit_cb; /* Called after the process exits. */
const char* file; /* Path to program to execute. */
/*
* Command line arguments. args[0] should be the path to the program. On
* Windows this uses CreateProcess which concatenates the arguments into a
* string this can cause some strange errors. See the note at
* windows_verbatim_arguments.
*/
char** args;
/*
* This will be set as the environ variable in the subprocess. If this is
* NULL then the parents environ will be used.
*/
char** env;
/*
* If non-null this represents a directory the subprocess should execute
* in. Stands for current working directory.
*/
const char* cwd;
/*
* Various flags that control how uv_spawn() behaves. See the definition of
* `enum uv_process_flags` below.
*/
unsigned int flags;
/*
* The `stdio` field points to an array of uv_stdio_container_t structs that
* describe the file descriptors that will be made available to the child
* process. The convention is that stdio[0] points to stdin, fd 1 is used for
* stdout, and fd 2 is stderr.
*
* Note that on windows file descriptors greater than 2 are available to the
* child process only if the child processes uses the MSVCRT runtime.
*/
int stdio_count;
uv_stdio_container_t* stdio;
/*
* When starting the child with a PTY, these set the initial width and
* height.
*/
unsigned int pty_cols;
unsigned int pty_rows;
/*
* Libuv can change the child process' user/group id. This happens only when
* the appropriate bits are set in the flags fields. This is not supported on
* windows; uv_spawn() will fail and set the error to UV_ENOTSUP.
*/
uv_uid_t uid;
uv_gid_t gid;
} uv_process_options2_t;

/*
* These are the flags that can be used for the uv_process_options.flags field.
*/
Expand Down Expand Up @@ -1160,7 +1219,16 @@ enum uv_process_flags {
* search for the exact file name before trying variants with
* extensions like '.exe' or '.cmd'.
*/
UV_PROCESS_WINDOWS_FILE_PATH_EXACT_NAME = (1 << 7)
UV_PROCESS_WINDOWS_FILE_PATH_EXACT_NAME = (1 << 7),
/*
* Start subprocess with a pseudo terminal. To use this flag, set
* stdio[0] to UV_CREATE_PIPE | UV_READABLE_PIPE and
* stdio[1] to UV_CREATE_PIPE | UV_WRITABLE_PIPE and
* stdio[2] to UV_IGNORE. The first pipe will be the PTY in (write here),
* while the second pipe will be the PTY out (read here). The child will have
* all standard FDs (0, 1 and 2) connected to the PTY as it should.
*/
UV_PROCESS_PTY = (1 << 8)
};

/*
Expand All @@ -1176,6 +1244,12 @@ struct uv_process_s {
UV_EXTERN int uv_spawn(uv_loop_t* loop,
uv_process_t* handle,
const uv_process_options_t* options);
UV_EXTERN int uv_spawn2(uv_loop_t* loop,
uv_process_t* handle,
const uv_process_options2_t* options);
UV_EXTERN int uv_pty_resize(uv_process_t* process,
unsigned short cols,
unsigned short rows);
UV_EXTERN int uv_process_kill(uv_process_t*, int signum);
UV_EXTERN int uv_kill(int pid, int signum);
UV_EXTERN uv_pid_t uv_process_get_pid(const uv_process_t*);
Expand Down
1 change: 1 addition & 0 deletions deps/uv/include/uv/win.h
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ typedef struct {
int exit_signal; \
HANDLE wait_handle; \
HANDLE process_handle; \
HANDLE pty_handle; \
volatile char exit_cb_pending;

#define UV_FS_PRIVATE_FIELDS \
Expand Down
Loading