The two traditional terminal hardware interfaces, termio structures in the System V and stty structures in Berkeley Software Distribution (BSD), have been replaced in POSIX with the termios structure and a new set of access calls.
The input/output (I/O) model is very similar to the System V model. Two modes exist: canonical and noncanonical. Canonical input is line-based, like BSD cooked mode. Noncanonical mode is character-based, like BSD raw or cbreak mode. The Interix subsystem includes a true, noncanonical mode, with support for cc_c[VMIN] and cc_c[VTIME].
The termios structure is defined in <termios.h>:
struct termios {
tcflag_t c_iflag; /* input mode */
tcflag_t c_oflag; /* output mode */
tcflag_t c_cflag; /* control mode */
tcflag_t c_lflag; /* local mode */
speed_t c_ispeed; /* input speed */
speed_t c_ospeed; /* output speed */
cc_t c_cc[NCCS]; /* control characters */
};
The Interix Software Development Kit (SDK) extends the POSIX.1 set of flags for c_iflag to include IMAXBEL and VBELTIME. For c_cc, VMIN and VTIME do not have the same values as VEOF and VEOL. When you create a portable application, however, you should take into consideration that VMIN and VTIME can be identical to VEOF and VEOL on a POSIX.1 system.
The following new functions replace the terminal I/O ioctl() calls, which include ioctl(fd, TIOCSETP, buf) and ioctl(fd, TIOCGETP, buf) or stty() and gtty(). They were changed because the data type of the final argument for terminal I/O ioctl() calls depends on an action that makes type checking impossible. Instead, the following twelve functions are defined:
Function | Description |
---|---|
tcgetattr() | Fetches attributes (termios structure) |
tcsetattr() | Sets attributes (termios structure) |
cfgetispeed() | Gets input speed |
cfgetospeed() | Gets output speed |
cfsetispeed() | Sets input speed |
cfsetospeed() | Sets output speed |
tcdrain() | Waits for all output to be transmitted |
tcflow() | Suspends transmit or receive |
tcflush() | Flushes pending I/O |
tcsendbreak() | Sends BREAK character |
tcgetpgrp() | Gets foreground process group identifier (ID) |
tcsetpgrp() | Sets foreground process group ID |
If you need to get the window size, the TIOCGWINSZ command for ioctl() and the winsize structure are both supported.