ioctl
![]() |
![]() |
![]() |
![]() |
ioctl()
Control a device
Synopsis:
#include <sys/ioctl.h>
int ioctl( int fd,
int request,
... );
Arguments:
- fd
- An open file descriptor for the file or device that you want to manipulate.
- request
- What you want to do to the file. The macros and definitions that you use in specifying a request are located in the file <sys/ioctl.h>.
- Additional arguments
- As required by the request.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The ioctl() function manipulates the underlying parameters of files. In particular, it can be used to control many of the operating attributes of files (such as the attributes of terminals).
The request argument determines whether the subsequent arguments are an "in" or "out" parameter; it also specifies the size of the arguments in bytes.
Returns:
A value based on the request, or -1 if an error occurs (errno is set).
Errors:
- EBADF
- Invalid descriptor fd.
- EINVAL
- The request or optional variables aren't valid.
- ENOTTY
- The fd argument isn't associated with a character special device; the specified request doesn't apply to the kind of object that the descriptor fd references.
Classification:
| Safety: | |
|---|---|
| Cancellation point | No |
| Interrupt handler | No |
| Signal handler | No |
| Thread | No |
Caveats:
The ioctl() function is a Unix function that varies greatly from platform to platform.
See also:
![]() |
![]() |
![]() |
![]() |

![[Previous]](../prev.gif)
![[Contents]](../contents.gif)
![[Index]](../keyword_index.gif)
![[Next]](../next.gif)
