copyediting for Usenix manuals
[unix-history] / usr / src / lib / libc / sys / ioctl.2
CommitLineData
aaea5b2e
KB
1.\" Copyright (c) 1980, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
384b8076 3.\"
931b8415 4.\" %sccs.include.redist.man%
384b8076 5.\"
653ba8b6 6.\" @(#)ioctl.2 8.2 (Berkeley) %G%
931b8415
CL
7.\"
8.Dd
9.Dt IOCTL 2
10.Os BSD 4
11.Sh NAME
12.Nm ioctl
13.Nd control device
14.Sh SYNOPSIS
15.Fd #include <sys/ioctl.h>
16.Ft int
17.Fn ioctl "int d" "unsigned long request" "char *argp"
18.Sh DESCRIPTION
19The
20.Fn ioctl
21function manipulates the underlying device parameters of special files.
22In particular, many operating
6234b5e5
KM
23characteristics of character special files (e.g. terminals)
24may be controlled with
931b8415 25.Fn ioctl
6234b5e5 26requests.
931b8415
CL
27The argument
28.Fa d
29must be an open file descriptor.
30.Pp
6234b5e5 31An ioctl
931b8415
CL
32.Fa request
33has encoded in it whether the argument is an
34.Dq in
35parameter
36or
37.Dq out
38parameter, and the size of the argument
39.Fa argp
40in bytes.
6234b5e5 41Macros and defines used in specifying an ioctl
931b8415 42.Fa request
6234b5e5 43are located in the file
931b8415
CL
44.Ao Pa sys/ioctl.h Ac .
45.Sh RETURN VALUES
46If an error has occurred, a value of -1 is returned and
47.Va errno
6234b5e5 48is set to indicate the error.
931b8415
CL
49.Sh ERRORS
50.Fn Ioctl
653ba8b6 51will fail if:
931b8415
CL
52.Bl -tag -width [ENOTTY]
53.It Bq Er EBADF
54.Fa d
55is not a valid descriptor.
56.It Bq Er ENOTTY
57.Fa d
58is not associated with a character
6234b5e5 59special device.
931b8415 60.It Bq Er ENOTTY
6234b5e5 61The specified request does not apply to the kind
931b8415
CL
62of object that the descriptor
63.Fa d
64references.
65.It Bq Er EINVAL
66.Fa Request
67or
68.Fa argp
69is not valid.
70.El
71.Sh SEE ALSO
72.Xr mt 1 ,
73.Xr execve 2 ,
74.Xr fcntl 2 ,
75.Xr tty 4 ,
76.Xr intro 4
77.Sh HISTORY
78An
79.Nm
80function call appeared in Version 7 AT&T UNIX.