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

# tty\_ioctl(4)

ioctls for terminals and serial lines

Part of [ioctl\_tty(2)](/ioctl_tty/2.md).

## 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)](/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)](/termios/7.md) whenever possible.

### Get and set terminal attributes

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

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

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

  ### Locking the termios structure

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

  ### Get and set window size

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

  ### Sending a break

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

  ### Software flow control

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

  ### Buffer count and flushing

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

  ### Faking input

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

  ### Redirecting console output

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

  ### Controlling terminal

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

  ### Process group and session ID

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

  ### Exclusive mode

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

  ### Line discipline

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

  ### Pseudoterminal ioctls

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

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

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

  ### Modem control

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

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

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

  ### Marking a line as local

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

  ### Linux-specific

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

### Kernel debugging

- [**TIOCTTYGSTRUCT**(2const)](/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)](/ioctl/2.md), [**ldattach**(8)](/ldattach/8.md), [**ioctl\_console**(2)](/ioctl_console/2.md), [**termios**(7)](/termios/7.md), [**pty**(7)](/pty/7.md)
