From 44f5c048edf736d356e124809a797f8185705cd0 Mon Sep 17 00:00:00 2001 From: "Taylor R. Campbell" Date: Sat, 31 Dec 2005 20:02:16 +0000 Subject: [PATCH] Fix several bugs in the new console resizing code: - Move initialization of terminal sizes out of UX_initialize_tty and into a new function, UX_reinitialize_tty, which does not also initialize the stdin/stdout channels, and which UX_initialize_tty calls. - Call UX_reinitialize_tty, not UX_initialize_tty, in the SIGWINCH handler, so that it will not reallocate the stdin/stdout channels and potentially overflow the channel table. - Don't distribute the CONSOLE-RESIZE event in the CONSOLE-RESIZE interrupt handler, since its receivers (recipients?) may perform arbitrary computation that should not be performed in interrupt handlers. Instead, signal a thread event to the console thread, if there is one, that will distribute the CONSOLE-RESIZE event. --- v7/src/microcode/uxsig.c | 6 +++--- v7/src/microcode/uxtty.c | 21 ++++++++++++++------- v7/src/runtime/intrpt.scm | 8 ++++++-- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/v7/src/microcode/uxsig.c b/v7/src/microcode/uxsig.c index a8871a0f1..bdc13537e 100644 --- a/v7/src/microcode/uxsig.c +++ b/v7/src/microcode/uxsig.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: uxsig.c,v 1.43 2005/12/25 17:04:39 riastradh Exp $ +$Id: uxsig.c,v 1.44 2005/12/31 20:02:16 riastradh Exp $ Copyright 1990,1991,1992,1993,1994,1996 Massachusetts Institute of Technology Copyright 2000,2001,2005 Massachusetts Institute of Technology @@ -497,8 +497,8 @@ DEFUN_VOID (OS_restartable_exit) static DEFUN_STD_HANDLER (sighnd_console_resize, { - extern void EXFUN (UX_initialize_tty, (void)); - UX_initialize_tty (); + extern void EXFUN (UX_reinitialize_tty, (void)); + UX_reinitialize_tty (); request_console_resize_interrupt (); }) diff --git a/v7/src/microcode/uxtty.c b/v7/src/microcode/uxtty.c index e24fb2ac3..fa06b5b7b 100644 --- a/v7/src/microcode/uxtty.c +++ b/v7/src/microcode/uxtty.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: uxtty.c,v 1.12 2003/02/14 18:28:24 cph Exp $ +$Id: uxtty.c,v 1.13 2005/12/31 20:02:16 riastradh Exp $ Copyright (c) 1990-1999 Massachusetts Institute of Technology @@ -107,14 +107,10 @@ DEFUN (tputs_write_char, (c), char c) } void -DEFUN_VOID (UX_initialize_tty) +DEFUN_VOID (UX_reinitialize_tty) { extern int EXFUN (atoi, (CONST char *)); - extern Tchannel EXFUN (OS_open_fd, (int fd)); - input_channel = (OS_open_fd (STDIN_FILENO)); - (CHANNEL_INTERNAL (input_channel)) = 1; - output_channel = (OS_open_fd (STDOUT_FILENO)); - (CHANNEL_INTERNAL (output_channel)) = 1; + tty_x_size = (-1); tty_y_size = (-1); tty_command_beep = ALERT_STRING; @@ -186,3 +182,14 @@ DEFUN_VOID (UX_initialize_tty) tty_command_clear = command; } } + +void +DEFUN_VOID (UX_initialize_tty) +{ + extern Tchannel EXFUN (OS_open_fd, (int fd)); + input_channel = (OS_open_fd (STDIN_FILENO)); + (CHANNEL_INTERNAL (input_channel)) = 1; + output_channel = (OS_open_fd (STDOUT_FILENO)); + (CHANNEL_INTERNAL (output_channel)) = 1; + UX_reinitialize_tty (); +} diff --git a/v7/src/runtime/intrpt.scm b/v7/src/runtime/intrpt.scm index 30dbdd10e..3e9825310 100644 --- a/v7/src/runtime/intrpt.scm +++ b/v7/src/runtime/intrpt.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: intrpt.scm,v 14.26 2005/12/25 17:04:39 riastradh Exp $ +$Id: intrpt.scm,v 14.27 2005/12/31 20:02:16 riastradh Exp $ Copyright 1986,1987,1988,1990,1991,1992 Massachusetts Institute of Technology Copyright 1993,1994,2004,2005 Massachusetts Institute of Technology @@ -127,7 +127,11 @@ USA. (define (console-resize-handler interrupt-code interrupt-enables) interrupt-code interrupt-enables (clear-interrupts! interrupt-bit/global-3) - (event-distributor/invoke! event:console-resize)) + (cond ((console-thread) + => (lambda (thread) + (signal-thread-event thread + (lambda () + (event-distributor/invoke! event:console-resize))))))) (define ((illegal-interrupt-handler interrupt-bit) interrupt-code interrupt-enables) -- 2.25.1