2.9BSD/usr/man/cat2/ioctl.2
IOCTL(2) UNIX Programmer's Manual IOCTL(2)
NAME
ioctl, stty, gtty - control device
SYNOPSIS
#include <sgtty.h>
ioctl(fildes, request, argp)
struct sgttyb *argp;
stty(fildes, argp)
struct sgttyb *argp;
gtty(fildes, argp)
struct sgttyb *argp;
DESCRIPTION
_I_o_c_t_l performs a variety of functions on character special
files (devices). The writeups of various devices in section
4 discuss how _i_o_c_t_l applies to them.
For certain status setting and status inquiries about termi-
nal devices, the functions _s_t_t_y and _g_t_t_y are equivalent to
ioctl(fildes, TIOCSETP, argp)
ioctl(fildes, TIOCGETP, argp)
respectively; see _t_t_y(4).
The following two calls, however, apply to any open file:
ioctl(fildes, FIOCLEX, NULL);
ioctl(fildes, FIONCLEX, NULL);
The first causes the file to be closed automatically during
a successful _e_x_e_c operation; the second reverses the effect
of the first.
RETURN VALUE
Upon successful completion, a value of 0 is returned. Oth-
erwise, a value of -1 is returned and _e_r_r_n_o is set to indi-
cate the error.
ERRORS
_I_o_c_t_l will fail if one or more of the following is true:
[EBADF] _F_i_l_d_e_s is not a valid descriptor.
[ENOTTY] _F_i_l_d_e_s is not associated with a charac-
ter special device.
[ENOTTY] The specified request does not apply to
the kind of object that the descriptor
_f_i_l_d_e_s references.
Printed 5/26/83 1
IOCTL(2) UNIX Programmer's Manual IOCTL(2)
[EINVAL] _R_e_q_u_e_s_t or _a_r_g_p is not valid.
SEE ALSO
stty(1), execve(2), exec(3), tty(4)
BUGS
Strictly speaking, since _i_o_c_t_l may be extended in different
ways to devices with different properties, _a_r_g_p should have
an open-ended declaration like
union { struct sgttyb ...; ... } *argp;
The important thing is that the size is fixed by `struct
sgttyb'.
ASSEMBLER
(ioctl = 54.)
sys ioctl; fildes; request; argp
(stty = 31.)
(file descriptor in r0)
stty; argp
(gtty = 32.)
(file descriptor in r0)
sys gtty; argp
Printed 5/26/83 2