aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-11-26 22:14:18 +0100
committerJustin M. Keyes <justinkz@gmail.com>2018-11-27 01:14:55 +0100
commit7fdb45e0f8b2dfc367067c62e413dd8082d770d5 (patch)
tree7bc6ca50659f2e80d0105974a850f9f2f420bc9c
parent60f845ca55a1b8b11a4eb390b1fed93a79e99ad5 (diff)
downloadrneovim-7fdb45e0f8b2dfc367067c62e413dd8082d770d5.tar.gz
rneovim-7fdb45e0f8b2dfc367067c62e413dd8082d770d5.tar.bz2
rneovim-7fdb45e0f8b2dfc367067c62e413dd8082d770d5.zip
preserve_exit: Ignore SIGHUP
closes #9274 ref #9028 If stdin closed then read_error_exit calls preserve_exit. Handling SIGHUP during preserve_exit would cause a premature teardown, and conflicts with e.g. ui_bridge_stop which waits for TUI to teardown. Vim ignores SIGHUP in its prepare_to_exit and getout_preserve_modified routines: /* Ignore SIGHUP, because a dropped connection causes a read error, which * makes Vim exit and then handling SIGHUP causes various reentrance * problems. */ signal(SIGHUP, SIG_IGN);
-rw-r--r--src/nvim/misc1.c3
-rw-r--r--src/nvim/ui_bridge.c1
-rw-r--r--test/functional/autocmd/termclose_spec.lua2
3 files changed, 6 insertions, 0 deletions
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index 4032210213..d8730ea08a 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -52,6 +52,7 @@
#include "nvim/window.h"
#include "nvim/os/os.h"
#include "nvim/os/shell.h"
+#include "nvim/os/signal.h"
#include "nvim/os/input.h"
#include "nvim/os/time.h"
#include "nvim/event/stream.h"
@@ -2653,6 +2654,8 @@ void preserve_exit(void)
}
really_exiting = true;
+ // Ignore SIGHUP while we are already exiting. #9274
+ signal_reject_deadly();
mch_errmsg(IObuff);
mch_errmsg("\n");
ui_flush();
diff --git a/src/nvim/ui_bridge.c b/src/nvim/ui_bridge.c
index eb592694e6..bd5d37be73 100644
--- a/src/nvim/ui_bridge.c
+++ b/src/nvim/ui_bridge.c
@@ -117,6 +117,7 @@ static void ui_bridge_stop(UI *b)
if (stopped) { // -V547
break;
}
+ // TODO(justinmk): Remove this. Use a cond-wait above. #9274
loop_poll_events(&main_loop, 10); // Process one event.
}
uv_thread_join(&bridge->ui_thread);
diff --git a/test/functional/autocmd/termclose_spec.lua b/test/functional/autocmd/termclose_spec.lua
index db4e5379d0..62eac59b16 100644
--- a/test/functional/autocmd/termclose_spec.lua
+++ b/test/functional/autocmd/termclose_spec.lua
@@ -6,6 +6,7 @@ local clear, command, nvim, nvim_dir =
local eval, eq, retry =
helpers.eval, helpers.eq, helpers.retry
local ok = helpers.ok
+local feed = helpers.feed
local iswin = helpers.iswin
@@ -87,5 +88,6 @@ describe('TermClose event', function()
command('3bdelete!')
retry(nil, nil, function() eq('3', eval('g:abuf')) end)
+ feed('<c-c>:qa!<cr>')
end)
end)