man(1) Manual page archive


     IOCTL(2)                                                 IOCTL(2)

     NAME
          ioctl - miscellaneous control operations

     SYNOPSIS
          #include <sys/filio.h>

          int ioctl(fildes, request, param)
          void *param;

     DESCRIPTION
          Ioctl performs a variety of requests on open files, most
          applying only to particular device files.  The writeups of
          various devices in section 4 discuss how ioctl applies to
          them; see stream(4) in particular for operations applying to
          communication devices.

          Param points to a parameter buffer.  Some requests read data
          from the buffer; others write data to the buffer; some do
          both.  The buffer's size varies according to the request.  A
          few provide meaningful data in the return value from ioctl
          as well; others return a conventional value of 0 for suc-
          cess, -1 for failure.

          Requests for different drivers are defined in different
          header files.  Two standard calls, defined in <sys/filio.h>,
          apply to any open file:

               ioctl(fildes, FIOCLEX, (void *)0);
               ioctl(fildes, FIONCLEX, (void *)0);

          The first causes the file to be closed automatically upon a
          successful exec(2); the second causes the file to be left
          open.

     SEE ALSO
          exec(2), stream(4)

     DIAGNOSTICS
          EBADF, EFAULT, EIO, ENODEV, ENOTTY

     BUGS
          Ioctl requests vary among UNIX systems; undisciplined use is
          likely to compromise portability.
          The size of the parameter buffer should be an explicit argu-
          ment.