ttyio

Name

ttyio -- tty ioctl commands

Synopsis

#include <sys/ioctl.h>
#include <fcntl.h>

int ioctl(int fd, unsigned long request, int * argp);

Description

Tty ioctl commands are a subset of the ioctl() calls, which can perform a variety of functions on tty devices. fd shall be an open file descriptor referring to a terminal device.

The following ioctl()s are provided:

TIOCGWINSZ 

Get the size attributes of the terminal or pseudo-terminal identified by fd. On entry, argp shall reference a winsize structure. On return, the structure will have ws_row set to the number of rows of text (i.e. lines of text) that can be viewed on the device, and ws_col set to the number of columns (i.e. text width).

Note: The number of columns stored in ws_col assumes that the terminal device is using a mono-spaced font.

TIOCSWINSZ 

Sets the size attributes of the terminal or pseudo-terminal identified by fd. On entry, argp shall reference a winsize structure. The value of the winsize structure's element ws_row shall be the number of rows of text (i.e. lines of text) that can be viewed on the device, and the element ws_col shall be the number of columns (i.e. text width). Note that this call merely sets the size attributes for the kernel driver, not the window size itself, and is intended to be used to update the kernel driver when the window size is changed.

Return Value

On success, 0 is returned. On error, -1 is returned and the global variable errno is set appropriately.

Errors

EBADF 

fd is not a valid descriptor.

EFAULT 

argp references an inaccessible memory area.

EINVAL 

request and argp are not valid.