mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 17:36:29 +00:00
Add overlapped option to jobstart
When UV_OVERLAPPED_PIPE was used for the pipe passed to the child process, a problem occurred with the standard input of the .Net Framework application (#11809). Therefore, add the overlapped option to jobstart() and change it so that it is set only when necessary
This commit is contained in:
@@ -301,7 +301,8 @@ static void close_cb(Stream *stream, void *data)
|
||||
/// @returns [allocated] channel
|
||||
Channel *channel_job_start(char **argv, CallbackReader on_stdout,
|
||||
CallbackReader on_stderr, Callback on_exit,
|
||||
bool pty, bool rpc, bool detach, const char *cwd,
|
||||
bool pty, bool rpc, bool overlapped, bool detach,
|
||||
const char *cwd,
|
||||
uint16_t pty_width, uint16_t pty_height,
|
||||
char *term_name, char **env, varnumber_T *status_out)
|
||||
{
|
||||
@@ -342,6 +343,7 @@ Channel *channel_job_start(char **argv, CallbackReader on_stdout,
|
||||
proc->detach = detach;
|
||||
proc->cwd = cwd;
|
||||
proc->env = env;
|
||||
proc->overlapped = overlapped;
|
||||
|
||||
char *cmd = xstrdup(proc->argv[0]);
|
||||
bool has_out, has_err;
|
||||
|
@@ -4862,6 +4862,7 @@ static void f_jobstart(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
bool rpc = false;
|
||||
bool pty = false;
|
||||
bool clear_env = false;
|
||||
bool overlapped = false;
|
||||
CallbackReader on_stdout = CALLBACK_READER_INIT,
|
||||
on_stderr = CALLBACK_READER_INIT;
|
||||
Callback on_exit = CALLBACK_NONE;
|
||||
@@ -4873,12 +4874,23 @@ static void f_jobstart(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
rpc = tv_dict_get_number(job_opts, "rpc") != 0;
|
||||
pty = tv_dict_get_number(job_opts, "pty") != 0;
|
||||
clear_env = tv_dict_get_number(job_opts, "clear_env") != 0;
|
||||
overlapped = tv_dict_get_number(job_opts, "overlapped") != 0;
|
||||
|
||||
if (pty && rpc) {
|
||||
EMSG2(_(e_invarg2), "job cannot have both 'pty' and 'rpc' options set");
|
||||
shell_free_argv(argv);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
if (pty && overlapped) {
|
||||
EMSG2(_(e_invarg2),
|
||||
"job cannot have both 'pty' and 'overlapped' options set");
|
||||
shell_free_argv(argv);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
char *new_cwd = tv_dict_get_string(job_opts, "cwd", false);
|
||||
if (new_cwd && strlen(new_cwd) > 0) {
|
||||
cwd = new_cwd;
|
||||
@@ -4945,7 +4957,7 @@ static void f_jobstart(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
}
|
||||
|
||||
Channel *chan = channel_job_start(argv, on_stdout, on_stderr, on_exit, pty,
|
||||
rpc, detach, cwd, width, height,
|
||||
rpc, overlapped, detach, cwd, width, height,
|
||||
term_name, env, &rettv->vval.v_number);
|
||||
if (chan) {
|
||||
channel_create_event(chan, NULL);
|
||||
@@ -7372,8 +7384,8 @@ static void f_rpcstart(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
|
||||
Channel *chan = channel_job_start(argv, CALLBACK_READER_INIT,
|
||||
CALLBACK_READER_INIT, CALLBACK_NONE,
|
||||
false, true, false, NULL, 0, 0, NULL, NULL,
|
||||
&rettv->vval.v_number);
|
||||
false, true, false, false, NULL, 0, 0,
|
||||
NULL, NULL, &rettv->vval.v_number);
|
||||
if (chan) {
|
||||
channel_create_event(chan, NULL);
|
||||
}
|
||||
@@ -10461,7 +10473,7 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
|
||||
uint16_t term_width = MAX(0, curwin->w_width_inner - win_col_off(curwin));
|
||||
Channel *chan = channel_job_start(argv, on_stdout, on_stderr, on_exit,
|
||||
true, false, false, cwd,
|
||||
true, false, false, false, cwd,
|
||||
term_width, curwin->w_height_inner,
|
||||
xstrdup("xterm-256color"), NULL,
|
||||
&rettv->vval.v_number);
|
||||
|
@@ -52,7 +52,7 @@ int libuv_process_spawn(LibuvProcess *uvproc)
|
||||
if (!proc->in.closed) {
|
||||
uvproc->uvstdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE;
|
||||
#ifdef WIN32
|
||||
uvproc->uvstdio[0].flags |= UV_OVERLAPPED_PIPE;
|
||||
uvproc->uvstdio[0].flags |= proc->overlapped ? UV_OVERLAPPED_PIPE : 0;
|
||||
#endif
|
||||
uvproc->uvstdio[0].data.stream = STRUCT_CAST(uv_stream_t,
|
||||
&proc->in.uv.pipe);
|
||||
@@ -61,8 +61,9 @@ int libuv_process_spawn(LibuvProcess *uvproc)
|
||||
if (!proc->out.closed) {
|
||||
uvproc->uvstdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE;
|
||||
#ifdef WIN32
|
||||
// pipe must be readable for IOCP to work.
|
||||
uvproc->uvstdio[1].flags |= UV_READABLE_PIPE | UV_OVERLAPPED_PIPE;
|
||||
// pipe must be readable for IOCP to work on Windows.
|
||||
uvproc->uvstdio[1].flags |= proc->overlapped ?
|
||||
(UV_READABLE_PIPE | UV_OVERLAPPED_PIPE) : 0;
|
||||
#endif
|
||||
uvproc->uvstdio[1].data.stream = STRUCT_CAST(uv_stream_t,
|
||||
&proc->out.uv.pipe);
|
||||
|
@@ -27,7 +27,7 @@ struct process {
|
||||
Stream in, out, err;
|
||||
process_exit_cb cb;
|
||||
internal_process_cb internal_exit_cb, internal_close_cb;
|
||||
bool closed, detach;
|
||||
bool closed, detach, overlapped;
|
||||
MultiQueue *events;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user