mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #6595 from justinmk/term-refresh-on-exit
This commit is contained in:
commit
4c3d7b29ec
@ -449,7 +449,7 @@ void close_buffer(win_T *win, buf_T *buf, int action, int abort_if_last)
|
||||
|
||||
if (buf->terminal) {
|
||||
terminal_close(buf->terminal, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* Always remove the buffer when there is no file name. */
|
||||
if (buf->b_ffname == NULL)
|
||||
|
@ -20,9 +20,9 @@
|
||||
# include "event/process.c.generated.h"
|
||||
#endif
|
||||
|
||||
// Time for a process to exit cleanly before we send KILL.
|
||||
#define KILL_TIMEOUT_MS 2000
|
||||
#define KILL_TIMEOUT_NS (KILL_TIMEOUT_MS * 1000000)
|
||||
// Time (ns) for a process to exit cleanly before we send TERM/KILL.
|
||||
#define TERM_TIMEOUT 1000000000
|
||||
#define KILL_TIMEOUT (TERM_TIMEOUT * 2)
|
||||
|
||||
#define CLOSE_PROC_STREAM(proc, stream) \
|
||||
do { \
|
||||
@ -121,6 +121,8 @@ void process_teardown(Loop *loop) FUNC_ATTR_NONNULL_ALL
|
||||
// Close handles to process without killing it.
|
||||
CREATE_EVENT(loop->events, process_close_handles, 1, proc);
|
||||
} else {
|
||||
uv_kill(proc->pid, SIGTERM);
|
||||
proc->term_sent = true;
|
||||
process_stop(proc);
|
||||
}
|
||||
}
|
||||
@ -242,16 +244,12 @@ void process_stop(Process *proc) FUNC_ATTR_NONNULL_ALL
|
||||
abort();
|
||||
}
|
||||
|
||||
ILOG("Sending SIGTERM to pid %d", proc->pid);
|
||||
uv_kill(proc->pid, SIGTERM);
|
||||
|
||||
Loop *loop = proc->loop;
|
||||
if (!loop->children_stop_requests++) {
|
||||
// When there's at least one stop request pending, start a timer that
|
||||
// will periodically check if a signal should be send to the job.
|
||||
// will periodically check if a signal should be send to a to the job
|
||||
DLOG("Starting job kill timer");
|
||||
uv_timer_start(&loop->children_kill_timer, children_kill_cb,
|
||||
KILL_TIMEOUT_MS, 100);
|
||||
uv_timer_start(&loop->children_kill_timer, children_kill_cb, 100, 100);
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,7 +267,11 @@ static void children_kill_cb(uv_timer_t *handle)
|
||||
}
|
||||
uint64_t elapsed = now - proc->stopped_time;
|
||||
|
||||
if (elapsed >= KILL_TIMEOUT_NS) {
|
||||
if (!proc->term_sent && elapsed >= TERM_TIMEOUT) {
|
||||
ILOG("Sending SIGTERM to pid %d", proc->pid);
|
||||
uv_kill(proc->pid, SIGTERM);
|
||||
proc->term_sent = true;
|
||||
} else if (elapsed >= KILL_TIMEOUT) {
|
||||
ILOG("Sending SIGKILL to pid %d", proc->pid);
|
||||
uv_kill(proc->pid, SIGKILL);
|
||||
}
|
||||
|
@ -26,7 +26,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, term_sent, detach;
|
||||
MultiQueue *events;
|
||||
};
|
||||
|
||||
@ -48,6 +48,7 @@ static inline Process process_init(Loop *loop, ProcessType type, void *data)
|
||||
.err = NULL,
|
||||
.cb = NULL,
|
||||
.closed = false,
|
||||
.term_sent = false,
|
||||
.internal_close_cb = NULL,
|
||||
.internal_exit_cb = NULL,
|
||||
.detach = false
|
||||
|
@ -302,8 +302,16 @@ void terminal_close(Terminal *term, char *msg)
|
||||
}
|
||||
|
||||
term->forward_mouse = false;
|
||||
term->closed = true;
|
||||
|
||||
// flush any pending changes to the buffer
|
||||
if (!exiting) {
|
||||
block_autocmds();
|
||||
refresh_terminal(term);
|
||||
unblock_autocmds();
|
||||
}
|
||||
|
||||
buf_T *buf = handle_get_buffer(term->buf_handle);
|
||||
term->closed = true;
|
||||
|
||||
if (!msg || exiting) {
|
||||
// If no msg was given, this was called by close_buffer(buffer.c). Or if
|
||||
|
Loading…
Reference in New Issue
Block a user