Seth Woolley's Man Viewer

ioctl(2) - ioctl, ioctl - control device - man 2 ioctl

([section] manual, -k keyword, -K [section] search, -f whatis)
man plain no title

IOCTL(2)                   Linux Programmer's Manual                  IOCTL(2)

       ioctl - control device

       #include <sys/ioctl.h>

       int ioctl(int d, int request, ...);

       The ioctl function manipulates the underlying device parameters of spe-
       cial files.  In particular, many operating characteristics of character
       special  files  (e.g. terminals) may be controlled with ioctl requests.
       The argument d must be an open(2,3,n) file(1,n) descriptor.

       The second argument is a  device-dependent  request  code.   The  third
       argument  is  an  untyped  pointer  to memory.  It's traditionally char
       *argp (from the days before void * was valid C), and will be  so  named(5,8)
       for this discussion.

       An ioctl request has encoded in(1,8) it whether the argument is an in(1,8) param-
       eter or out parameter, and the size of  the  argument  argp  in(1,8)  bytes.
       Macros  and  defines used in(1,8) specifying an ioctl request are located in(1,8)
       the file(1,n) <sys/ioctl.h>.

       Usually, on success zero is returned.  A  few  ioctls  use  the  return
       value as an output parameter and return a nonnegative value on success.
       On error(8,n), -1 is returned, and errno is set(7,n,1 builtins) appropriately.

       EBADF  d is not a valid descriptor.

       EFAULT argp references an inaccessible memory area.

       EINVAL Request or argp is not valid.

       ENOTTY d is not associated with a character special device.

       ENOTTY The specified request does not apply to the kind of object  that
              the descriptor d references.

       In  order  to  use this call, one needs an open(2,3,n) file(1,n) descriptor.  Often
       the open(2,3,n)(2) call has unwanted side effects, that can be  avoided  under
       Linux by giving it the O_NONBLOCK flag.

       No single standard.  Arguments, returns, and semantics of ioctl(2) vary
       according to the device driver in(1,8) question  (the  call  is  used  as  a
       catch-all  for  operations  that  don't cleanly fit the Unix stream I/O
       model). See ioctl_list(2) for a list of many of the known ioctl  calls.
       The ioctl function call appeared in(1,8) Version 7 AT&T Unix.

       execve(2), fcntl(2), ioctl_list(2), open(2,3,n)(2), mt(4), sd(4), tty(1,4)(4)

BSD Man Page                      2000-09-21                          IOCTL(2)

References for this manual (incoming links)