myadm

Simple MySQL client for the terminal
git clone git://git.bitsmanent.org/myadm
Log | Files | Refs | README | LICENSE

commit 14935088271224c69c32f251b7575efecbd59333
parent 9e507ecf20e70a8331d22f3a3ccc962469e0d123
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Tue, 10 May 2016 20:19:00 +0200

Fix editfile().
Don't even call endwin(). Just take off and restore ncurses signal handlers.

Diffstat:
Mmyadm.c | 19++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/myadm.c b/myadm.c @@ -291,15 +291,14 @@ void editfile(char *file) { pid_t pid; int rc = -1; - - ui_end(); /* endwin() */ + struct sigaction saold[4]; /* take off ncurses signal handlers */ struct sigaction sa = {.sa_flags = 0, .sa_handler = SIG_DFL}; - sigaction(SIGINT, &sa, NULL); - sigaction(SIGTERM, &sa, NULL); - sigaction(SIGTSTP, &sa, NULL); - sigaction(SIGWINCH, &sa, NULL); + sigaction(SIGINT, &sa, &saold[0]); + sigaction(SIGTERM, &sa, &saold[1]); + sigaction(SIGTSTP, &sa, &saold[2]); + sigaction(SIGWINCH, &sa, &saold[3]); if((pid = fork()) == 0) { execl("/bin/sh", "sh", "-c", "$EDITOR \"$0\"", file, NULL); @@ -309,7 +308,13 @@ editfile(char *file) { return; while(!WIFEXITED(rc)) waitpid(pid, &rc, 0); - ui_init(); /* restore ncurses signal handlers */ + + /* restore ncurses signal handlers */ + sigaction(SIGINT, &saold[0], NULL); + sigaction(SIGTERM, &saold[1], NULL); + sigaction(SIGTSTP, &saold[2], NULL); + sigaction(SIGWINCH, &saold[3], NULL); + ui_redraw(); }