From: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Linux PPC devel <linuxppc-dev@ozlabs.org>,
Jeremy Fitzhardinge <jeremy@goop.org>,
Rusty Russell <rusty@rustcorp.com.au>,
"Ryan S. Arnold" <rsa@us.ibm.com>,
LKML <linux-kernel@vger.kernel.org>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: Re: [RFC PATCH 2/5] hvc_console: Add tty driver flag TTY_DRIVER_RESET_TERMIOS
Date: Thu, 16 Oct 2008 13:09:50 +0200 [thread overview]
Message-ID: <20081016110950.GA4125@cetus.boeblingen.de.ibm.com> (raw)
In-Reply-To: <20081014104025.517ae734@lxorguk.ukuu.org.uk>
Hello,
for the sake of completion, here are few more details why I have suggest to
add the TTY_DRIVER_RESET_TERMIOS flag:
On Tue, Oct 14, 2008 at 10:40:25AM +0100, Alan Cox wrote:
> On Tue, 14 Oct 2008 11:12:49 +0200
> Hendrik Brueckner <brueckner@linux.vnet.ibm.com> wrote:
>
> > After a tty hangup() or close() operation, processes might not reset the
> > termio settings to a sane state.
> That is the job of the getty task normally. pty is special as the reissue
> of the same pty is done as a new device (with new state).
During some testing, I have experienced that the bash alters few termios
settings before showing the bash prompt:
-
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, TCSETSW, {B38400 opost isig -icanon -echo ...}) = 0
write(2, "root@t6345050:~# ", 17) = 17
-
If the tty gets a hangup, the bash gets terminated but the settings still
remains after init has respawned the getty process.
For my network-based hvc backend, a tty_hangup() is caused by a disconnect.
I looked into the tty_io.c source and found out that the termios settings
are stored in an array of the tty driver struct and they remains unchanged
if a tty device is released and initialized again.
At tty device initialization, the tty_init_termios() set tty->termios to the
tty->driver->termios[tty->index].
The idea is to ensure that when a tty is initialized it has the
default (initial) termio settings; and that is actually done if
TTY_DRIVER_RESET_TERMIOS is set.
Anyhow the other possibility might be to always set the initial termios
when the tty is initialized (see patch below).
But I am not sure if that case is the general behavior of ttys.
Please let me know if there is a reason not to re-initialize the termios
of a new tty.
Thanks.
Best regards
Hendrik
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
---
drivers/char/tty_io.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
--- a/drivers/char/tty_io.c 2008-10-16 09:48:00.000000000 +0200
+++ b/drivers/char/tty_io.c 2008-10-16 12:55:52.000000000 +0200
@@ -1243,10 +1243,9 @@ int tty_init_termios(struct tty_struct *
tp = kzalloc(sizeof(struct ktermios[2]), GFP_KERNEL);
if (tp == NULL)
return -ENOMEM;
- memcpy(tp, &tty->driver->init_termios,
- sizeof(struct ktermios));
tty->driver->termios[idx] = tp;
}
+ memcpy(tp, &tty->driver->init_termios, sizeof(struct ktermios));
tty->termios = tp;
tty->termios_locked = tp + 1;
--
Hendrik Brueckner
D/3303 Linux on System z Development
Tel: +49 7031 16-1073
Fax: +49 7031 16-3456
eMail: brueckner@linux.vnet.ibm.com
IBM Deutschland Research & Development GmbH, Schoenaicher Str. 220, 71032 Boeblingen
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Erich Baier
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
next prev parent reply other threads:[~2008-10-16 11:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-14 9:12 [RFC PATCH 0/5] patches for a network-based hvc backend (s390) Hendrik Brueckner
2008-10-14 9:12 ` [RFC PATCH 1/5] hvc_console: Adding hangup notifier Hendrik Brueckner
2008-10-14 9:12 ` [RFC PATCH 2/5] hvc_console: Add tty driver flag TTY_DRIVER_RESET_TERMIOS Hendrik Brueckner
2008-10-14 9:40 ` Alan Cox
2008-10-16 11:09 ` Hendrik Brueckner [this message]
2008-10-16 12:18 ` Alan Cox
2008-10-14 9:12 ` [RFC PATCH 3/5] hvc_console: Fix loop if put_char() returns 0 Hendrik Brueckner
2008-10-14 9:12 ` [RFC PATCH 4/5] hvc_console: Add tty window resizing Hendrik Brueckner
2008-10-14 9:44 ` Alan Cox
2008-10-14 15:02 ` Hendrik Brueckner
2008-10-14 16:14 ` Alan Cox
2008-10-16 11:41 ` Rusty Russell
2008-10-16 11:58 ` Christian Borntraeger
2008-10-14 9:12 ` [RFC PATCH 5/5] hvc_console: Remove __devexit annotation of hvc_remove() Hendrik Brueckner
2008-10-20 23:23 ` [RFC PATCH 0/5] patches for a network-based hvc backend (s390) Benjamin Herrenschmidt
2008-10-21 7:42 ` Hendrik Brueckner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081016110950.GA4125@cetus.boeblingen.de.ibm.com \
--to=brueckner@linux.vnet.ibm.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=benh@kernel.crashing.org \
--cc=borntraeger@de.ibm.com \
--cc=heiko.carstens@de.ibm.com \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=rsa@us.ibm.com \
--cc=rusty@rustcorp.com.au \
--cc=schwidefsky@de.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®