IOCTL(2)

NAME
ioctl - miscellaneous control operations

SYNOPSIS
#include <sgtty.h>

int ioctl(fildes, request, argp)
struct sgttyb *argp;

DESCRIPTION
Ioctl performs a variety of functions on special files and streams. The writeups of various devices in section 4 discuss how ioctl applies to them.

Some calls, however, apply to any open file, including the process-exclusive calls FIOPX, FIONPX, and FIOQX (see pex(4)), as well as the following two standard calls,

    ioctl(fildes, FIOCLEX, (void *)0);
    ioctl(fildes, FIONCLEX, (void *)0);

The first causes the file to be closed automatically upon a successful exec(2); the second causes the file to be left open.

SEE ALSO
stty(1), exec(2), proc(4), ttyld(4)

DIAGNOSTICS
EBADF, EFAULT, EIO, ELAB, ENODEV, ENOTTY

BUGS
Strictly speaking, since ioctl may be extended in different ways to devices with different properties, argp should have an open-ended declaration like

    union { struct sgttyb ...; ... } *argp;

The important thing is that the size is at least sizeof(struct sgttyb).
Ioctl requests vary among UNIX systems; undisciplined use is likely to compromise portability.