diff options
author | anton <anton@cvs.openbsd.org> | 2017-06-25 08:31:45 +0000 |
---|---|---|
committer | anton <anton@cvs.openbsd.org> | 2017-06-25 08:31:45 +0000 |
commit | 9b1ea8f90f53a59b9f03d7c9adbca9578f8729c0 (patch) | |
tree | daee015123e9f758cac4ed4edbb08fea30815bfe | |
parent | 37ff4a4cf84214e77306cd4ea040dbe9d22d0b19 (diff) |
Capture SIGINT and print out all received output so far. Useful when debugging
broken tests.
-rw-r--r-- | regress/bin/ksh/edit/edit.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/regress/bin/ksh/edit/edit.c b/regress/bin/ksh/edit/edit.c index 247e0b0ab2e..500875ec8ff 100644 --- a/regress/bin/ksh/edit/edit.c +++ b/regress/bin/ksh/edit/edit.c @@ -25,10 +25,10 @@ #include <unistd.h> #include <util.h> -static void sigchld(int); +static void sighandler(int); static void __dead usage(void); -static volatile sig_atomic_t gotsigchld; +static volatile sig_atomic_t gotsig; int main(int argc, char *argv[]) @@ -59,8 +59,10 @@ main(int argc, char *argv[]) nin += n; } - if (signal(SIGCHLD, sigchld) == SIG_ERR) - err(1, "signal"); + if (signal(SIGCHLD, sighandler) == SIG_ERR) + err(1, "signal: SIGCHLD"); + if (signal(SIGINT, sighandler) == SIG_ERR) + err(1, "signal: SIGINT"); memset(&ws, 0, sizeof(ws)); ws.ws_col = 80, @@ -77,7 +79,7 @@ main(int argc, char *argv[]) nread = nwrite = 0; pfd.fd = ptyfd; pfd.events = (POLLIN | POLLOUT); - while (!gotsigchld) { + while (!gotsig) { nready = poll(&pfd, 1, 10); if (nready == -1) { if (errno == EINTR) @@ -122,9 +124,9 @@ main(int argc, char *argv[]) } static void -sigchld(int sig) +sighandler(int sig) { - gotsigchld = sig == SIGCHLD; + gotsig = sig; } static void __dead |