commit c336d9a1b5bc4763a15b91c40b92f5c951dca2fd
parent 78f53b2adb9100baf25a415db34884dc11c82d6d
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Fri, 24 Oct 2014 22:30:38 +0000
simplify, also dont call cleanup twice on sigterm
Diffstat:
M | sob.c | | | 17 | ++++------------- |
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/sob.c b/sob.c
@@ -66,7 +66,6 @@ static int pipe_read(int, int, char *,
static int pipe_cmd(char *[], char *,
void (*)(const char *, size_t, size_t));
-static void cleanup(void);
static void clear(void);
static void gettermsize(void);
static void handleinput(const unsigned char *, size_t);
@@ -742,7 +741,6 @@ sighandler(int signum)
switch(signum) {
case SIGTERM:
isrunning = 0;
- cleanup();
break;
case SIGWINCH:
clear();
@@ -786,14 +784,6 @@ resize(void)
}
static void
-cleanup(void)
-{
- ttystate.c_lflag = ttysave.c_lflag;
- /* set the terminal attributes. */
- tcsetattr(STDIN_FILENO, TCSANOW, &ttystate);
-}
-
-static void
handleinput(const unsigned char *input, size_t len)
{
size_t p = 0, keylen, i;
@@ -956,12 +946,13 @@ main(int argc, char **argv)
/* setup tty again because we (re)open "/dev/tty" */
setup();
}
-
/* clear screen */
clear();
-
run();
- cleanup();
+
+ /* cleanup: restore terminal attributes. */
+ ttystate.c_lflag = ttysave.c_lflag;
+ tcsetattr(STDIN_FILENO, TCSANOW, &ttystate);
return EXIT_SUCCESS;
}