vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

commit 00609a358ceb048d8a8b74df8369426e49468552
parent 6773153a6a54c531ad60e89e42fbd531b62cb8fa
Author: yiyus <none@none>
Date:   Fri,  9 Jul 2010 22:35:55 +0200

restore tty state in more cases

Diffstat:
src/9vx/a/devcons.c | 2++
src/9vx/a/fns.h | 2++
src/9vx/osx/screen.c | 3+++
src/9vx/stub.c | 1+
src/9vx/tty.c | 12+++++++++---
src/9vx/x11/x11-init.c | 1+
src/9vx/x11/x11-kernel.c | 6++++--
7 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/src/9vx/a/devcons.c b/src/9vx/a/devcons.c @@ -300,6 +300,7 @@ panic(char *fmt, ...) putstrn(buf, n+1); dumpstack(); + restoretty(); exit(1); } @@ -483,6 +484,7 @@ echo(char *buf, int n) killbig("^t ^t k"); return; case 'r': + restoretty(); exit(0); return; } diff --git a/src/9vx/a/fns.h b/src/9vx/a/fns.h @@ -174,6 +174,8 @@ void __punlock(Psleep*); void __pwakeup(Psleep*); void __psleep(Psleep*); +void restoretty(void); + extern int tracelock; #define lockfngen(type) __ ## type diff --git a/src/9vx/osx/screen.c b/src/9vx/osx/screen.c @@ -209,6 +209,7 @@ cmdhandler(EventHandlerCallRef next, EventRef event, void *arg) static OSStatus quithandler(EventHandlerCallRef next, EventRef event, void *arg) { + restoretty(); // XXX: should we? exit(0); return 0; } @@ -233,6 +234,7 @@ eventhandler(EventHandlerCallRef next, EventRef event, void *arg) typeHICommand, nil, sizeof cmd, nil, &cmd); switch(cmd.commandID){ case kHICommandQuit: + restoretty(); // XXX: should we? exit(0); case CmdFullScreen: @@ -247,6 +249,7 @@ eventhandler(EventHandlerCallRef next, EventRef event, void *arg) case kEventClassWindow:; switch(GetEventKind(event)){ case kEventWindowClosed: + restoretty(); // XXX: should we? exit(0); case kEventWindowBoundsChanged: diff --git a/src/9vx/stub.c b/src/9vx/stub.c @@ -529,6 +529,7 @@ panic(char *fmt, ...) va_end(arg); buf[n] = '\n'; write(2, buf, n+1); + restoretty(); if(doabort){ #ifdef __APPLE__ fprint(2, "sleeping, so you can attach gdb to pid %d\n", (int)getpid()); diff --git a/src/9vx/tty.c b/src/9vx/tty.c @@ -26,7 +26,7 @@ uartputs(char *buf, int n) } void -restoretty(int sig) +restoretty(void) { static struct termios ttmode; @@ -34,6 +34,12 @@ restoretty(int sig) ttmode.c_lflag |= (ECHO|ICANON); tcsetattr(0, TCSANOW, &ttmode); } +} + +void +bye(int sig) +{ + restoretty(); exit(0); } @@ -55,8 +61,8 @@ uartreader(void *v) if(tcsetattr(0, TCSANOW, &ttmode) >= 0) ttyecho = 1; } - signal(SIGINT, restoretty); - signal(SIGTERM, restoretty); + signal(SIGINT, bye); + signal(SIGTERM, bye); while((n = read(0, buf, sizeof buf)) > 0) echo(buf, n); } diff --git a/src/9vx/x11/x11-init.c b/src/9vx/x11/x11-init.c @@ -49,6 +49,7 @@ static int xioerror(XDisplay *d) { /*print("X I/O error\n"); */ + restoretty(); exit(0); /*sysfatal("X I/O error\n");*/ abort(); diff --git a/src/9vx/x11/x11-kernel.c b/src/9vx/x11/x11-kernel.c @@ -61,8 +61,10 @@ runxevent(XEvent *xev) break; case DestroyNotify: - if(_xdestroy(xev)) - exit(0); + if(_xdestroy(xev)){ + restoretty(); + bye(0); + } break; case ConfigureNotify: