From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nikju-0000pc-OX for qemu-devel@nongnu.org; Sat, 20 Feb 2010 03:31:04 -0500 Received: from [199.232.76.173] (port=39530 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nikjt-0000pD-Bh for qemu-devel@nongnu.org; Sat, 20 Feb 2010 03:31:01 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nikjr-0000KB-2a for qemu-devel@nongnu.org; Sat, 20 Feb 2010 03:31:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:5238) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nikjq-0000Jh-HP for qemu-devel@nongnu.org; Sat, 20 Feb 2010 03:30:58 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1K8UvlP001123 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 20 Feb 2010 03:30:57 -0500 Date: Sat, 20 Feb 2010 10:30:56 +0200 From: Shahar Havivi Message-ID: <20100220083052.GA3582@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH] terminal attributes is not restored when using /dev/tty monitor List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Dor Laor when exiting qemu that run with "-monitor /dev/tty", the launching terminal get weird behaviour because no restore terminals action has taken. added chr_close and register atexit() code for tty devices (like stdio does) Signed-off-by: Shahar Havivi --- qemu-char.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 75dbf66..de16883 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -1002,6 +1002,7 @@ static void tty_serial_init(int fd, int speed, speed, parity, data_bits, stop_bits); #endif tcgetattr (fd, &tty); + oldtty = tty; #define check_speed(val) if (speed <= val) { spd = B##val; break; } speed = speed * 10 / 11; @@ -1173,6 +1174,17 @@ static int tty_serial_ioctl(CharDriverState *chr, int cmd, void *arg) return 0; } +static void tty_exit(void) +{ + tcsetattr(0, TCSANOW, &oldtty); +} + +static void qemu_chr_close_tty(struct CharDriverState *chr) +{ + tty_exit(); + fd_chr_close(chr); +} + static CharDriverState *qemu_chr_open_tty(QemuOpts *opts) { const char *filename = qemu_opt_get(opts, "path"); @@ -1190,6 +1202,8 @@ static CharDriverState *qemu_chr_open_tty(QemuOpts *opts) return NULL; } chr->chr_ioctl = tty_serial_ioctl; + chr->chr_close = qemu_chr_close_tty; + atexit(tty_exit); return chr; } #else /* ! __linux__ && ! __sun__ */ -- 1.6.3.3