mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: Andreas Schwab <schwab@suse.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Pty is losing bytes
Date: Tue, 15 Feb 2005 12:56:52 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.58.0502151239160.2330@ppc970.osdl.org> (raw)
In-Reply-To: <je1xbhy3ap.fsf@sykes.suse.de>



On Tue, 15 Feb 2005, Andreas Schwab wrote:
>
> Linus Torvalds <torvalds@osdl.org> writes:
> 
> > I think it may be a n_tty line discipline bug, brought on by the fact that
> > the PTY buffering is now 4kB rather than 2kB. 4kB is also the
> > N_TTY_BUF_SIZE, and if n_tty has some off-by-one error, that would explain 
> > it.
> 
> I've also seen more than one byte missing.  For example when sending a big
> chunk of bytes down the pty via an Emacs *shell* buffer up to 16 bytes are
> missing somewhere in the middle.

If it's NTTY (and I'm pretty certain it is - the generic tty code looks 
fine, the pty code itself is too simple for words), then I'd actually have 
expected more variability than a simple off-by-one. 

I'd have expected the problems to be due to character expansion, ie the
CR->LF thing etc, and that would have resulted in off-by-N, where N is the
number of expanded characters in a 4096 byte block. With XTAB, you could
even have each \t be expanded to 8 space characters on ECHO, and you could
lose a whole lot more than just one byte at the end.

That's clearly not the case, and I haven't looked into exactly what
termios settings "forkpty()" uses, so I suspect that it's something else
than pure expansion on write. There's a lot of things going on in a tty
driver: the character flow itself, the "backflow" in the form of ECHO, etc
etc.

Also, there's the interaction with "flushing" the buffer: we do a 
"flush_chars()" at regular intervals, and that will flush it to the next 
buffer, which may actually cause things to fit a lot better than they
would otherwise have fit. In fact, I'd not be at all surprised if this
thing was timing-dependent too, ie depended on how quickly the reader 
emptied the other side buffer.

The tty layer is pretty ugly, but in its defense, it has to be said that
tty handling _is_ one of the more complex parts of traditional UNIX, so 
the ugliness is at least partly due to the problem space, not just the 
fact that the code is old.

		Linus

  reply	other threads:[~2005-02-15 20:59 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-15  0:54 Andreas Schwab
2005-02-15 19:08 ` Linus Torvalds
2005-02-15 19:44   ` Linus Torvalds
2005-02-15 22:13     ` Alan Cox
2005-02-15 19:58   ` Sergey Vlasov
2005-02-15 20:13     ` Sergey Vlasov
2005-02-15 20:06   ` Alan Curry
2005-02-15 20:30   ` Andreas Schwab
2005-02-15 20:56     ` Linus Torvalds [this message]
2005-02-15 21:54       ` Andreas Schwab
2005-02-16  3:12       ` Roman Zippel
2005-02-16  4:05         ` Linus Torvalds
2005-02-16 14:42           ` Theodore Ts'o
2005-02-16 16:06             ` Linus Torvalds
2005-02-17  4:44               ` Theodore Ts'o
2005-02-17 15:45                 ` Linus Torvalds
2005-02-18 16:32                   ` Theodore Ts'o
2005-02-16 19:49           ` Roman Zippel
2005-02-16 19:58             ` Linus Torvalds
2005-02-16 22:46               ` Andrew Morton
2005-02-15  2:00 Alex Davis
2005-02-15 10:48 ` Andreas Schwab
2005-02-15 11:01   ` Jan De Luyck

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=Pine.LNX.4.58.0502151239160.2330@ppc970.osdl.org \
    --to=torvalds@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=schwab@suse.de \
    /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®