Console (tty01) ioctl() failure - SCO

This is a discussion on Console (tty01) ioctl() failure - SCO ; I use the following to determine how many bytes are waiting in the terminal input. int ret = 0; int bytes = 0; errno = 0; ret = ioctl(STDIN_FILENO,I_NREAD,&bytes); fprintf(stderr,"errno = %d, ret = %d, bytes = %d\n",errno,ret,bytes); It works ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Console (tty01) ioctl() failure

  1. Console (tty01) ioctl() failure

    I use the following to determine how many bytes are waiting in the
    terminal input.

    int ret = 0;
    int bytes = 0;
    errno = 0;
    ret = ioctl(STDIN_FILENO,I_NREAD,&bytes);

    fprintf(stderr,"errno = %d, ret = %d, bytes = %d\n",errno,ret,bytes);

    It works find everywhere except on the /dev/tty01, or other physical
    console "windows" on SCO. Even worse, the ioctl() call above puts the
    video into 40 column mode.

    Why is the above ioctl() call changing the video mode, and how can I
    find out how many bytes are in STDIN_FILENO (fd 0) after using
    select() or poll() to detect the handle is read ready?

    cj


  2. Re: Console (tty01) ioctl() failure

    In article <1190994133.767764.80010@k79g2000hse.googlegroups.c om>,
    CJ wrote:
    >I use the following to determine how many bytes are waiting in the
    >terminal input.
    >
    > int ret = 0;
    > int bytes = 0;
    > errno = 0;
    > ret = ioctl(STDIN_FILENO,I_NREAD,&bytes);
    >
    > fprintf(stderr,"errno = %d, ret = %d, bytes = %d\n",errno,ret,bytes);
    >
    >It works find everywhere except on the /dev/tty01, or other physical
    >console "windows" on SCO. Even worse, the ioctl() call above puts the
    >video into 40 column mode.
    >
    >Why is the above ioctl() call changing the video mode, and how can I
    >find out how many bytes are in STDIN_FILENO (fd 0) after using
    >select() or poll() to detect the handle is read ready?


    This problem stems from a conflict between the numbering for STREAMS ioctls and
    the OSR5 console mode switch ioctls. A fix for OSR5 is included in MP5; it
    recognizes a STREAMS ioctl attempt by the fact that it has a valid pointer for
    the 3rd argument, while a mode-switch ioctl should have 0. The ioctl will then
    fail correctly (without switching the video mode), since the console is not a
    STREAMS device.

    Some variation on this also happens in OSR6, though it might only occur if you
    are running an OSR5 ABI binary - I don't remember.

    What to do about it depends on what release of the OS you're running.

    John
    --
    John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/

+ Reply to Thread