aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/channel.h2
-rw-r--r--src/nvim/event/proc.c5
-rw-r--r--src/nvim/msgpack_rpc/channel.c14
3 files changed, 8 insertions, 13 deletions
diff --git a/src/nvim/channel.h b/src/nvim/channel.h
index 81d67ceb66..d7149efcae 100644
--- a/src/nvim/channel.h
+++ b/src/nvim/channel.h
@@ -40,7 +40,7 @@ struct Channel {
CallbackReader on_data;
CallbackReader on_stderr;
Callback on_exit;
- int exit_status;
+ int exit_status; ///< Process exit-code (if the channel wraps a process).
bool callback_busy;
bool callback_scheduled;
diff --git a/src/nvim/event/proc.c b/src/nvim/event/proc.c
index e32bbbc29a..1a5e01eb9d 100644
--- a/src/nvim/event/proc.c
+++ b/src/nvim/event/proc.c
@@ -437,11 +437,6 @@ static void on_proc_exit(Proc *proc)
Loop *loop = proc->loop;
ILOG("child exited: pid=%d status=%d" PRIu64, proc->pid, proc->status);
- // XXX: This assumes the TUI never spawns any other processes...?
- if (ui_client_channel_id) {
- exit_on_closed_chan(proc->status);
- }
-
// Process has terminated, but there could still be data to be read from the
// OS. We are still in the libuv loop, so we cannot call code that polls for
// more data directly. Instead delay the reading after the libuv loop by
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c
index fa50afd83b..1d24198455 100644
--- a/src/nvim/msgpack_rpc/channel.c
+++ b/src/nvim/msgpack_rpc/channel.c
@@ -486,15 +486,15 @@ void rpc_close(Channel *channel)
channel->rpc.closed = true;
channel_decref(channel);
- if (ui_client_channel_id && channel->id == ui_client_channel_id) {
- assert(!channel->detach); // `Channel.detach` is not currently used by the UI client.
- exit_on_closed_chan(0);
- } else if (channel->streamtype == kChannelStreamStdio) {
- // Avoid hanging when there are no other UIs and a prompt is triggered on exit.
- remote_ui_disconnect(channel->id);
+ bool is_ui_client = ui_client_channel_id && channel->id == ui_client_channel_id;
+ if (is_ui_client || channel->streamtype == kChannelStreamStdio) {
+ if (!is_ui_client) {
+ // Avoid hanging when there are no other UIs and a prompt is triggered on exit.
+ remote_ui_disconnect(channel->id);
+ }
if (!channel->detach) {
- exit_on_closed_chan(0);
+ exit_on_closed_chan(channel->exit_status == -1 ? 0 : channel->exit_status);
}
}
}