Move signal handling to libuv event loop

This removes all signal handling code from os_unix.c to os/signal.c. Now signal
handling is done like this:

- Watchers for signals are registered with libuv default event loop
- `event_poll` continuously calls `poll_uv_loop` to produce events until it
  receives user input, SIGINT or a timeout
- Any signals received in `poll_uv_loop` will push events to a queue that is
  drained and processed by `event_poll`

Signals aren't handled directly in the libuv callback to avoid recursion in the
event loop(which isn't supported by libuv).

The same principle will apply to other events in the future: Push to a queue
from a libuv callback and drain it from `event_poll`
This commit is contained in:
Thiago de Arruda
2014-04-01 08:54:31 -03:00
parent 40879af7bd
commit 774f668c43
10 changed files with 295 additions and 608 deletions

View File

@@ -34,6 +34,7 @@
#include "os_unix.h"
#include "os/time.h"
#include "os/input.h"
#include "os/signal.h"
#include "screen.h"
#include "term.h"
#include "window.h"
@@ -145,7 +146,7 @@ ui_inchar (
/* If we are going to wait for some time or block... */
if (wtime == -1 || wtime > 100L) {
/* ... allow signals to kill us. */
(void)vim_handle_signal(SIGNAL_UNBLOCK);
signal_accept_deadly();
/* ... there is no need for CTRL-C to interrupt something, don't let
* it set got_int when it was mapped. */
@@ -161,7 +162,7 @@ ui_inchar (
if (wtime == -1 || wtime > 100L)
/* block SIGHUP et al. */
(void)vim_handle_signal(SIGNAL_BLOCK);
signal_reject_deadly();
ctrl_c_interrupts = TRUE;