Re: Inserting flow-control chars with an mpsafetty kernel



Hello Giorgos,

* Giorgos Keramidas <keramida@xxxxxxxxxxxxxxx> 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@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
gone, right?

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
bloat.

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.

- Both.

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@xxxxxxxx>
WWW: http://80386.nl/

Attachment: pgpYU0eObBXdb.pgp
Description: PGP signature



Relevant Pages

  • Re: Inserting flow-control chars with an mpsafetty kernel
    ... ^Q characters cannot be inserted inserted anymore. ... and type in insert-mode `^V^S'. ... TTY code, but it is not so directly involved in the handling of the ... mode' (TIOCPKT). ...
    (freebsd-current)
  • Re: Inserting flow-control chars with an mpsafetty kernel
    ... TTY code, but it is not so directly involved in the handling of the ... but a shortcoming of the ptsdriver. ... mode' (TIOCPKT). ...
    (freebsd-current)
  • Re: finding number of characters in keyboard buffer?
    ... What's a convenient way to find the number of characters in the keyboard ... Only the tty driver knows about those ... (it's not a keyboard buffer, but quite probably a buffer in the tty ...
    (comp.os.minix)
  • Re: xPC Serial Communication Problems
    ... We're using the serial ports that come on the CPU ... The older serial block you're using uses the kernel resident driver ... Is the receiving machine executing at the 'same' 50 ms rate? ... does it wait until there are at least 15 characters in the ...
    (comp.soft-sys.matlab)
  • Re: Bytes
    ... architecture, for the following reasons: ... to make Windows NT driver support easier. ... convert between wide characters and multibyte characters and this is ... be simply mapped to multibyte characters in C, ...
    (comp.lang.forth)