[Openmcl-devel] Raw-mode terminal weirdness redux

David Brown lisp at davidb.org
Tue Mar 27 12:51:26 PDT 2018


On Tue, Mar 27, 2018 at 12:35:11PM -0700, Ron Garret wrote:
>
>On Mar 27, 2018, at 12:03 PM, R. Matthew Emerson <rme at acm.org> wrote:
>
>> I was under the faulty impression that #_cfmakeraw would fully initialize the termios structure.
>
>Same here.  The man page certainly does nothing to indicate otherwise.

I think the Linux manpage is a little better, but still not all that
clear:

       cfmakeraw() sets the terminal to something like the "raw" mode of the old  Version  7  terminal
       driver:  input  is  available character by character, echoing is disabled, and all special pro‐
       cessing of terminal input and output characters is disabled.  The terminal attributes  are  set
       as follows:

           termios_p->c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
                           | INLCR | IGNCR | ICRNL | IXON);
           termios_p->c_oflag &= ~OPOST;
           termios_p->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
           termios_p->c_cflag &= ~(CSIZE | PARENB);
           termios_p->c_cflag |= CS8;

which is pretty close to the implementation in glibc:

    void
    cfmakeraw (struct termios *t)
    {
      t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
      t->c_oflag &= ~OPOST;
      t->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
      t->c_cflag &= ~(CSIZE|PARENB);
      t->c_cflag |= CS8;
      t->c_cc[VMIN] = 1;            /* read returns when one char is available.  */
      t->c_cc[VTIME] = 0;
    }

I suspect the MacOS version initializes a little less, which might
explain why it never fails on Linux.

David



More information about the Openmcl-devel mailing list