IOCTL(2) System Calls Manual IOCTL(2)
ioctl - control device
int ioctl(fd, request, arg)
int fd, request;
ioctl() performs a special function on the object referred to by the
open descriptor fd. The set of functions that may be performed depends
on the object that fd refers to. For example, many operating charac-
teristics of character special files (for instance, terminals) may be
controlled with ioctl() requests. The writeups in section 4 discuss
how ioctl() applies to various objects.
The request codes for particular functions are specified in include
files specific to objects or to families of objects; the writeups in
section 4 indicate which include files specify which requests.
For most ioctl() functions, arg is a pointer to data to be used by the
function or to be filled in by the function. Other functions may
ignore arg or may treat it directly as a data item; they may, for exam-
ple, be passed an int value.
ioctl() returns 0 on success for most requests. Some specialized
requests may return non-zero values on success; see the description of
the request in the man page for the object. On failure, ioctl()
returns -1 and sets errno to indicate the error.
EBADF fd is not a valid descriptor.
EFAULT request requires a data transfer to or from a buffer
pointed to by arg, but some part of the buffer is out-
side the process's allocated space.
EINVAL request or arg is not valid.
ENOTTY The specified request does not apply to the kind of
object to which the descriptor fd refers.
ioctl() will also fail if the object on which the function is being
performed detects an error. In this case, an error code specific to the
object and the function will be returned.
execve(2V), fcntl(2V), filio(4), mtio(4), sockio(4), streamio(4),
21 January 1990 IOCTL(2)