Inserting flow-control chars with an mpsafetty kernel
ed at 80386.nl
Tue Aug 26 16:01:46 UTC 2008
* Giorgos Keramidas <keramida at ceid.upatras.gr> wrote:
> After installing the mpsafetty changes it seems that flow-control ^S and
> ^Q characters cannot be inserted inserted anymore. I first noticed this
> when CTRL-S stopped working as 'search-forward' in Emacs, but it seems
> the same problem exists in /usr/bin/vi, vim, bash and a few other
> programs that I tested.
> With a kernel before the mpsafetty changes, I can fire up /usr/bin/vi
> and type in insert-mode `^V^S'. This correctly inserts a ^S character.
> With a kernel from svn revision /head at 181939 ^V no longer quotes the
> next byte in vi(1) and other programs.
There is indeed a small problem w.r.t. ^S/^Q characters with the MPSAFE
TTY code, but it is not so directly involved in the handling of the
actual characters, but a shortcoming of the pts(4) driver.
There is this way a PTY (master device) can be configured to use `packet
mode' (TIOCPKT). When this mode is enabled, all data that is read() by
screen is prepended by a single byte, containing a bit mask of events.
These events include flush events, but also flags indicating tcsetattr()
has been called and has toggled VSTART/VSTOP.
When I implemented the pts(4) driver, I thought the idea behind TIOCPKT
is quite vague, because there is no real reason for pts(4) consumers to
know this information. They just receive the raw data and inject
keyboard actions. The pts(4) driver that lives in SVN now is a little
broken, because it never returns any special events. It just prepends
the data with a zero-byte, to keep the consumers happy.
Screen(1) is a fairly moronic written application, which uses packet
mode for no sensible reason at all. If you just comment out TIOCPKT in
/usr/include/sys/ttycom.h and recompile screen(1), your problems are
There are three ways ways to fix this problem:
- Implement a real packet mode which properly returns the TIOCPKT_*
flags. Unlike the previous TTY layer, it is a lot harder to do this
with MPSAFE TTY, because it turns the generic TTY code into more
The new TTY layer has been designed to be a real front-end for the
device driver. There aren't any driver hooks (yet) to detect the
events supported by TIOCPKT, because `normal drivers' don't need these
event notifications anyway.
- Remove TIOCPKT and TIOCPKT_* to <sys/ioctl_compat.h> and leave it
there to die. While there, also move definitions of other awkward
commands to this header.
I was planning to prepare a changeset soonish, which removes the (in my
opinion) deprecated ioctl()'s from our header files, so I can let the
ports folks run a tinderbox to see how much breaks. This should give us
a good estimation of the best approach.
Ed Schouten <ed at 80386.nl>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 195 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20080826/34133444/attachment.pgp
More information about the freebsd-current