From: David van Moolenbroek Date: Mon, 21 Dec 2009 23:19:01 +0000 (+0000) Subject: TTY fixes: X-Git-Tag: v3.1.6~141 X-Git-Url: http://zhaoyanbai.com/repos/man.dnssec-coverage.html?a=commitdiff_plain;h=492d6634441022e21b555b4f5786cfa48bab1e5e;p=minix.git TTY fixes: - reenable code to restore screen/cursor at shutdown - add proper signal checking logic - lock to first console during shutdown --- diff --git a/drivers/tty/console.c b/drivers/tty/console.c index 77108fd50..7fc93ecac 100644 --- a/drivers/tty/console.c +++ b/drivers/tty/console.c @@ -103,6 +103,8 @@ PRIVATE int nr_cons= 1; /* actual number of consoles */ PRIVATE console_t cons_table[NR_CONS]; PRIVATE console_t *curcons = NULL; /* currently visible */ +PRIVATE int shutting_down = FALSE; /* don't allow console switches */ + /* Color if using a color controller. */ #define color (vid_port == C_6845) @@ -1228,12 +1230,11 @@ PUBLIC void toggle_scroll() PUBLIC void cons_stop() { /* Prepare for halt or reboot. */ - select_console(0); -#if 0 cons_org0(); softscroll = 1; + select_console(0); cons_table[0].c_attr = cons_table[0].c_blank = BLANK_COLOR; -#endif + shutting_down = TRUE; } /*===========================================================================* @@ -1298,6 +1299,8 @@ PUBLIC void select_console(int cons_line) { /* Set the current console to console number 'cons_line'. */ + if (shutting_down) return; + if (cons_line < 0 || cons_line >= nr_cons) return; ccurrent = cons_line; diff --git a/drivers/tty/tty.c b/drivers/tty/tty.c index 8574bc62f..e2445b977 100644 --- a/drivers/tty/tty.c +++ b/drivers/tty/tty.c @@ -102,6 +102,7 @@ unsigned long rs_irq_set = 0; struct kmessages kmess; +FORWARD _PROTOTYPE( void got_signal, (void) ); FORWARD _PROTOTYPE( void tty_timed_out, (timer_t *tp) ); FORWARD _PROTOTYPE( void expire_timers, (void) ); FORWARD _PROTOTYPE( void settimer, (tty_t *tty_ptr, int enable) ); @@ -219,8 +220,8 @@ PUBLIC int main(void) expire_timers(); break; case PM_PROC_NR: - /* switch to primary console */ - cons_stop(); + /* signal */ + got_signal(); break; case SYSTEM: /* system signal */ @@ -343,6 +344,24 @@ PRIVATE void sef_local_startup() sef_startup(); } +/*===========================================================================* + * got_signal * + *===========================================================================*/ +PRIVATE void got_signal() +{ +/* PM notified us that we have received a signal. If it is a SIGTERM, assume + * that the system is shutting down. + */ + sigset_t set; + + if (getsigset(&set) != 0) return; + + if (!sigismember(&set, SIGTERM)) return; + + /* switch to primary console */ + cons_stop(); +} + /*===========================================================================* * do_status * *===========================================================================*/