ITEM: CH1674L

Controlling behavior of tty read operations with termios ioctl


Env
  AIX 3.2.5
  xlc 1.2.0

DESC:

Customer is doing an open() on a tty, then reading from it with read()
but the amount of data coming in is unknown, and if he does a read()
and there's no more data to read, the read() blocks indefinitely.
Customer would like the read() call to time out after a certain period
of time without any data being read.

ACT:
This can be accomplished with the VMIN and VTIME parameters of the
termios structure.

int fd;
struct termios tty;

fd = open("/dev/tty\#\#", O_RDWR|O_NDELAY);
ioctl(fd, TCGETA, &tty); /* Get current settings */
tty.c_cc[VMIN] = 0;      /* Minimum bytes read must read */
tty.c_cc[VTIME] = 255;   /* Maximum time read tries to read */
ioctl(fd, TCSETA, &term);/* Put new settings to use */
Your code here...


Support Line: Controlling behavior of tty read operations with termios ioctl ITEM: CH1674L
Dated: November 1996 Category: N/A
This HTML file was generated 99/06/24~13:30:17
Comments or suggestions? Contact us