---
name: "ioctl_tty"
section: "2"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://carta.tech/man/ioctl_tty"
---

# ioctl\_tty(2)

ioctls for terminals and serial lines

## NAME

ioctl\_tty - ioctls for terminals and serial lines

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#include <asm/termbits.h>  /* Definition of constants */
#include <sys/ioctl.h>
```

**int ioctl(int** *fd***, int** *op***, ...);**

## DESCRIPTION

The [**ioctl**(2)](/man/ioctl/2.md) call for terminals and serial ports accepts many possible operation arguments. Most require a third argument, of varying type, here called *argp* or *arg*.

Use of **ioctl**() makes for nonportable programs. Use the POSIX interface described in [**termios**(7)](/man/termios/7.md) whenever possible.

### Get and set terminal attributes

- [**TCGETS**(2const)](/man/TCGETS/2const.md) [**TCSETS**(2const)](/man/TCSETS/2const.md) [**TCSETSW**(2const)](/man/TCSETSW/2const.md) [**TCSETSF**(2const)](/man/TCSETSF/2const.md)

  - [**TCGETS2**(2const)](/man/TCGETS2/2const.md) [**TCSETS2**(2const)](/man/TCSETS2/2const.md) [**TCSETSW2**(2const)](/man/TCSETSW2/2const.md) [**TCSETSF2**(2const)](/man/TCSETSF2/2const.md)

  - [**TCGETA**(2const)](/man/TCGETA/2const.md) [**TCSETA**(2const)](/man/TCSETA/2const.md) [**TCSETAW**(2const)](/man/TCSETAW/2const.md) [**TCSETAF**(2const)](/man/TCSETAF/2const.md)

  ### Locking the termios structure

- [**TIOCGLCKTRMIOS**(2const)](/man/TIOCGLCKTRMIOS/2const.md) [**TIOCSLCKTRMIOS**(2const)](/man/TIOCSLCKTRMIOS/2const.md)

  ### Get and set window size

- [**TIOCGWINSZ**(2const)](/man/TIOCGWINSZ/2const.md) [**TIOCSWINSZ**(2const)](/man/TIOCSWINSZ/2const.md)

  ### Sending a break

- [**TCSBRK**(2const)](/man/TCSBRK/2const.md) [**TCSBRKP**(2const)](/man/TCSBRKP/2const.md) [**TIOCSBRK**(2const)](/man/TIOCSBRK/2const.md) [**TIOCCBRK**(2const)](/man/TIOCCBRK/2const.md)

  ### Software flow control

- [**TCXONC**(2const)](/man/TCXONC/2const.md)

  ### Buffer count and flushing

- [**FIONREAD**(2const)](/man/FIONREAD/2const.md) [**TIOCINQ**(2const)](/man/TIOCINQ/2const.md) [**TIOCOUTQ**(2const)](/man/TIOCOUTQ/2const.md) [**TCFLSH**(2const)](/man/TCFLSH/2const.md) [**TIOCSERGETLSR**(2const)](/man/TIOCSERGETLSR/2const.md)

  ### Faking input

- [**TIOCSTI**(2const)](/man/TIOCSTI/2const.md)

  ### Redirecting console output

- [**TIOCCONS**(2const)](/man/TIOCCONS/2const.md)

  ### Controlling terminal

- [**TIOCSCTTY**(2const)](/man/TIOCSCTTY/2const.md) [**TIOCNOTTY**(2const)](/man/TIOCNOTTY/2const.md)

  ### Process group and session ID

- [**TIOCGPGRP**(2const)](/man/TIOCGPGRP/2const.md) [**TIOCSPGRP**(2const)](/man/TIOCSPGRP/2const.md) [**TIOCGSID**(2const)](/man/TIOCGSID/2const.md)

  ### Exclusive mode

- [**TIOCEXCL**(2const)](/man/TIOCEXCL/2const.md) [**TIOCGEXCL**(2const)](/man/TIOCGEXCL/2const.md) [**TIOCNXCL**(2const)](/man/TIOCNXCL/2const.md)

  ### Line discipline

- [**TIOCGETD**(2const)](/man/TIOCGETD/2const.md) [**TIOCSETD**(2const)](/man/TIOCSETD/2const.md)

  ### Pseudoterminal ioctls

- [**TIOCPKT**(2const)](/man/TIOCPKT/2const.md) [**TIOCGPKT**(2const)](/man/TIOCGPKT/2const.md)

  - [**TIOCSPTLCK**(2const)](/man/TIOCSPTLCK/2const.md) [**TIOCGPTLCK**(2const)](/man/TIOCGPTLCK/2const.md)

  - [**TIOCGPTPEER**(2const)](/man/TIOCGPTPEER/2const.md)

  ### Modem control

- [**TIOCMGET**(2const)](/man/TIOCMGET/2const.md) [**TIOCMSET**(2const)](/man/TIOCMSET/2const.md) [**TIOCMBIC**(2const)](/man/TIOCMBIC/2const.md) [**TIOCMBIS**(2const)](/man/TIOCMBIS/2const.md)

  - [**TIOCMIWAIT**(2const)](/man/TIOCMIWAIT/2const.md)

  - [**TIOCGICOUNT**(2const)](/man/TIOCGICOUNT/2const.md)

  ### Marking a line as local

- [**TIOCGSOFTCAR**(2const)](/man/TIOCGSOFTCAR/2const.md) [**TIOCSSOFTCAR**(2const)](/man/TIOCSSOFTCAR/2const.md)

  ### Linux-specific

For the [**TIOCLINUX**(2const)](/man/TIOCLINUX/2const.md) ioctl, see [**ioctl\_console**(2)](/man/ioctl_console/2.md).

### Kernel debugging

- [**TIOCTTYGSTRUCT**(2const)](/man/TIOCTTYGSTRUCT/2const.md)

  ## RETURN VALUE

On success, 0 is returned. On error, -1 is returned, and *errno* is set to indicate the error.

## SEE ALSO

[**ioctl**(2)](/man/ioctl/2.md), [**ldattach**(8)](/man/ldattach/8.md), [**ioctl\_console**(2)](/man/ioctl_console/2.md), [**termios**(7)](/man/termios/7.md), [**pty**(7)](/man/pty/7.md)
