2.9BSD/usr/man/man2/ioctl.2

Compare this file to the similar file:
Show the results in this format:

.TH IOCTL 2 
.UC
.SH NAME
ioctl, stty, gtty \- control device
.SH SYNOPSIS
.B #include <sgtty.h>
.PP
.B ioctl(fildes, request, argp)
.br
.B struct sgttyb *argp;
.PP
.B stty(fildes, argp)
.br
.B struct sgttyb *argp;
.PP
.B gtty(fildes, argp)
.br
.B struct sgttyb *argp;
.SH DESCRIPTION
.I Ioctl
performs a variety of functions
on character special files (devices).
The writeups of various devices
in section 4 discuss how
.I ioctl
applies to them.
.PP
For certain status setting and status inquiries
about terminal devices, the functions
.I stty
and
.I gtty
are equivalent to
.RS
.B ioctl(fildes, TIOCSETP, argp)
.br
.B ioctl(fildes, TIOCGETP, argp)
.RE
.LP
respectively; see
.IR tty (4).
.PP
The following two calls, however, apply to any open file:
.PP
.RS
.B ioctl(fildes, FIOCLEX, NULL);
.br
.B ioctl(fildes, FIONCLEX, NULL);
.RE
.LP
The first causes the file to be closed automatically during
a successful
.I exec
operation;
the second reverses the effect of the first.
.SH RETURN VALUE
Upon successful completion, a value of 0 is returned.  Otherwise, a
value of \-1 is returned and
.I errno
is set to indicate the error.
.SH ERRORS
.I Ioctl
will fail if one or more of the following is true:
.TP 20
[EBADF]
.I Fildes
is not a valid descriptor.
.TP 20
[ENOTTY]
.I Fildes
is not associated with a character special device.
.TP 20
[ENOTTY]
The specified request does not apply to the kind of object that
the descriptor
.I fildes
references.
.TP 20
[EINVAL]
.IR Request " or " argp
is not valid.
.SH "SEE ALSO"
stty(1), execve(2), exec(3), tty(4)
.SH BUGS
Strictly speaking,
since 
.I ioctl
may be extended in different ways to devices with
different properties,
.I argp
should have an open-ended declaration like
.IP
.B union { struct sgttyb
.RB ... ;
\&...
.B } *argp;
.PP
The important thing is that the size is fixed by `struct sgttyb'.
.SH ASSEMBLER
(ioctl = 54.)
.br
.B sys ioctl; fildes; request; argp
.PP
(stty = 31.)
.br
(file descriptor in r0)
.br
.B stty; argp
.PP
(gtty = 32.)
.br
(file descriptor in r0)
.br
.B sys gtty; argp