xref: /csrg-svn/lib/libc/sys/ioctl.2 (revision 65100)
161181Sbostic.\" Copyright (c) 1980, 1991, 1993
261181Sbostic.\"	The Regents of the University of California.  All rights reserved.
320029Smckusick.\"
447208Scael.\" %sccs.include.redist.man%
520029Smckusick.\"
6*65100Smckusick.\"     @(#)ioctl.2	8.2 (Berkeley) 12/11/93
747208Scael.\"
847208Scael.Dd
947208Scael.Dt IOCTL 2
1047208Scael.Os BSD 4
1147208Scael.Sh NAME
1247208Scael.Nm ioctl
1347208Scael.Nd control device
1447208Scael.Sh SYNOPSIS
1547208Scael.Fd #include <sys/ioctl.h>
1647208Scael.Ft int
1747208Scael.Fn ioctl "int d" "unsigned long request" "char *argp"
1847208Scael.Sh DESCRIPTION
1947208ScaelThe
2047208Scael.Fn ioctl
2147208Scaelfunction manipulates the underlying device parameters of special files.
2247208ScaelIn particular, many operating
2320030Smckusickcharacteristics of character special files (e.g. terminals)
2420030Smckusickmay be controlled with
2547208Scael.Fn ioctl
2620030Smckusickrequests.
2747208ScaelThe argument
2847208Scael.Fa d
2947208Scaelmust be an open file descriptor.
3047208Scael.Pp
3120030SmckusickAn  ioctl
3247208Scael.Fa request
3347208Scaelhas encoded in it whether the argument is an
3447208Scael.Dq in
3547208Scaelparameter
3647208Scaelor
3747208Scael.Dq out
3847208Scaelparameter, and the size of the argument
3947208Scael.Fa argp
4047208Scaelin bytes.
4120030SmckusickMacros and defines used in specifying an ioctl
4247208Scael.Fa request
4320030Smckusickare located in the file
4447208Scael.Ao Pa sys/ioctl.h Ac .
4547208Scael.Sh RETURN VALUES
4647208ScaelIf an error has occurred, a value of -1 is returned and
4747208Scael.Va errno
4820030Smckusickis set to indicate the error.
4947208Scael.Sh ERRORS
5047208Scael.Fn Ioctl
51*65100Smckusickwill fail if:
5247208Scael.Bl -tag -width [ENOTTY]
5347208Scael.It Bq Er EBADF
5447208Scael.Fa d
5547208Scaelis not a valid descriptor.
5647208Scael.It Bq Er ENOTTY
5747208Scael.Fa d
5847208Scaelis not associated with a character
5920030Smckusickspecial device.
6047208Scael.It Bq Er ENOTTY
6120030SmckusickThe specified request does not apply to the kind
6247208Scaelof object that the descriptor
6347208Scael.Fa d
6447208Scaelreferences.
6547208Scael.It Bq Er EINVAL
6647208Scael.Fa Request
6747208Scaelor
6847208Scael.Fa argp
6947208Scaelis not valid.
7047208Scael.El
7147208Scael.Sh SEE ALSO
7247208Scael.Xr mt 1 ,
7347208Scael.Xr execve 2 ,
7447208Scael.Xr fcntl 2 ,
7547208Scael.Xr tty 4 ,
7647208Scael.Xr intro 4
7747208Scael.Sh HISTORY
7847208ScaelAn
7947208Scael.Nm
8047208Scaelfunction call appeared in Version 7 AT&T UNIX.
81