strange timing problem in /usr/ucb/Mail
Chris Torek
chris at mimsy.UUCP
Wed Aug 10 14:16:49 AEST 1988
In article <13 at catwoman.ACA.MCC.COM> ables at catwoman.ACA.MCC.COM (King
Ables) writes:
>We noticed a strange timing problem in /usr/ucb/Mail ...
>I suspect it exists from the original Berkeley code.
>The problem occurs [anytime you are editing a header, actually].
>... If the Cc: line has several addresses on it so that it wraps
>to a 2nd line AND if you hit ^D and <RETURN> (the <return> in
>response to the Cc: line prompt) VERY QUICKLY, there seems
>to be a timing problem where the 2nd line's worth of text (the
>part that was wrapped) isn't gathered up and processed so you
>wind up with a partial CC: line going out.
This description is flawed, but the effect is right: if you hit return
fast enough, part of the text intended for that line appears on the
next line (possibly the command). The same thing happens when using
~h, although for whatever reasons, people tend to be slower to bang on
the return key here.
The bug has existed ever since the TIOCSTI ioctl was added, and is very
simple and very hard to fix. The Mail program uses TIOCSTI (`Tty IO
Control, Simulate Terminal Input') to stuff characters into the tty
input queue, as if you had typed them yourself. You can then edit them
using the kernel tty input code. This is a nice way to implement
single-line editing, but it has a serious flaw: TIOCSTI does exactly
what it implies. The TIOCSTI ioctl passes a character to the tty input
code, where it is treated just as if you typed it just then. Hence if
you type *before* Mail gets around to doing a TIOCSTI, what you typed
goes in front of what Mail `types'. Moreover, if for some crazy reason
you like to use the letter `w' as your line kill character, when Mail
tries to push back the Cc line
aglew at gould.com
you wind up with the string
@gould.com
since the `w' did a line kill.
The best fix for the problem is to replace TIOCSTI with something
useful. At least two operations are needed, one to push a string in
front of the tty queue, and one to push it after; it would also help if
one could automatically quote any special characters. Alternatively,
one could remove tty line editing from the kernel entirely, and again
replace TIOCSTI with something useful, but outside the kernel.
Either way, just changing Mail will not do it.
(Another possibility is to make Mail run in cbreak mode, and have it
simulate the kernel's tty input editor. There is or was code in Mail
to do this. This solution is at least as unsatisfactory as TIOCSTI.)
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.unix.questions
mailing list