diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2017-05-08 13:49:23 +0200 |
|---|---|---|
| committer | Justin M. Keyes <justinkz@gmail.com> | 2017-05-08 13:49:23 +0200 |
| commit | 7c1a5d1d407e2e93e079a27b91f4c20b4fee1a0d (patch) | |
| tree | 072de0e4481d2786212a14a35c391aabbcb8014a /src/nvim/event/process.c | |
| parent | a6f74debc01b1d76713b392819d429de7d92f875 (diff) | |
| download | rneovim-7c1a5d1d407e2e93e079a27b91f4c20b4fee1a0d.tar.gz rneovim-7c1a5d1d407e2e93e079a27b91f4c20b4fee1a0d.tar.bz2 rneovim-7c1a5d1d407e2e93e079a27b91f4c20b4fee1a0d.zip | |
Revert "event/process.c: send SIGTERM directly (#6644)"
This reverts commit 34c3f03013375817d3d089e685793290eded553a.
Diffstat (limited to 'src/nvim/event/process.c')
| -rw-r--r-- | src/nvim/event/process.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c index 6aab7d903c..ffda10a494 100644 --- a/src/nvim/event/process.c +++ b/src/nvim/event/process.c @@ -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); } |