aboutsummaryrefslogtreecommitdiff
path: root/test/functional/fixtures/tty-test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/fixtures/tty-test.c')
-rw-r--r--test/functional/fixtures/tty-test.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/test/functional/fixtures/tty-test.c b/test/functional/fixtures/tty-test.c
index 40ba131003..778e7f3cd3 100644
--- a/test/functional/fixtures/tty-test.c
+++ b/test/functional/fixtures/tty-test.c
@@ -31,12 +31,24 @@ static void walk_cb(uv_handle_t *handle, void *arg) {
}
}
-static void sigwinch_handler(int signum)
+#ifndef WIN32
+static void sig_handler(int signum)
{
- int width, height;
- uv_tty_get_winsize(&tty, &width, &height);
- fprintf(stderr, "rows: %d, cols: %d\n", height, width);
+ switch(signum) {
+ case SIGWINCH: {
+ int width, height;
+ uv_tty_get_winsize(&tty, &width, &height);
+ fprintf(stderr, "rows: %d, cols: %d\n", height, width);
+ return;
+ }
+ case SIGHUP:
+ exit(42); // arbitrary exit code to test against
+ return;
+ default:
+ return;
+ }
}
+#endif
// static void sigwinch_cb(uv_signal_t *handle, int signum)
// {
@@ -135,16 +147,22 @@ int main(int argc, char **argv)
uv_tty_set_mode(&tty, UV_TTY_MODE_RAW);
tty.data = &interrupted;
uv_read_start((uv_stream_t *)&tty, alloc_cb, read_cb);
+#ifndef WIN32
struct sigaction sa;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
- sa.sa_handler = sigwinch_handler;
+ sa.sa_handler = sig_handler;
+ sigaction(SIGHUP, &sa, NULL);
sigaction(SIGWINCH, &sa, NULL);
// uv_signal_t sigwinch_watcher;
// uv_signal_init(uv_default_loop(), &sigwinch_watcher);
// sigwinch_watcher.data = &tty;
// uv_signal_start(&sigwinch_watcher, sigwinch_cb, SIGWINCH);
+#endif
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
+ // XXX: Without this the SIGHUP handler is skipped on some systems.
+ sleep(100);
+
return 0;
}