xref: /original-bsd/lib/libc/sys/ioctl.2 (revision 95ecee29)
1.\" Copyright (c) 1980, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)ioctl.2	8.2 (Berkeley) 12/11/93
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
23characteristics of character special files (e.g. terminals)
24may be controlled with
25.Fn ioctl
26requests.
27The argument
28.Fa d
29must be an open file descriptor.
30.Pp
31An  ioctl
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.
41Macros and defines used in specifying an ioctl
42.Fa request
43are located in the file
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
48is set to indicate the error.
49.Sh ERRORS
50.Fn Ioctl
51will fail if:
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
59special device.
60.It Bq Er ENOTTY
61The specified request does not apply to the kind
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.
81