commit 088944cffaac6c5ae538ad8f611a48d54f90783c
parent 6f02addad1b6c1f13090d951703a00edba6662c3
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sun, 26 Oct 2014 12:30:01 +0000
restore term attributes on SIGINT (Ctrl-c) properly
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/sob.c b/sob.c
@@ -672,6 +672,7 @@ pipe_cmd(char *cmd[], char *writestr, void (*f)(const char *, size_t, size_t))
setenv("SOBWRITE", writestr, 1);
close(cp[0]);
close(pc[1]);
+
if (dup2(pc[0], STDIN_FILENO) == -1 ||
dup2(cp[1], STDOUT_FILENO) == -1) {
perror("dup2");
@@ -741,8 +742,9 @@ static void
sighandler(int signum)
{
switch(signum) {
+ case SIGINT: /* fallthrough */
case SIGTERM:
- isrunning = 0;
+ line_exit();
break;
case SIGWINCH:
clear();
@@ -954,6 +956,7 @@ main(int argc, char **argv)
sa.sa_flags = SA_RESTART;
sa.sa_handler = sighandler;
sigaction(SIGTERM, &sa, NULL);
+ sigaction(SIGINT, &sa, NULL);
sigaction(SIGWINCH, &sa, NULL);
/* reap zombie childs >=) */
sa.sa_handler = SIG_IGN;
@@ -970,6 +973,5 @@ main(int argc, char **argv)
ttystate.c_lflag = ttysave.c_lflag;
tcsetattr(STDIN_FILENO, TCSANOW, &ttystate);
}
-
return EXIT_SUCCESS;
}