termios.h(0P)

🌸 termios.h(0P) β€” POSIX Programmer's Manual 🌸

okay bestie, welcome to the terminal-I/O header of your DREAMS. this page is termios.h(0P) from the POSIX Programmer's Manual, and it's giving "everything you need to boss your terminal around". buckle up 🫢


✨ PROLOG ✨

This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

πŸ’€ bestie. "may differ" and "may not be implemented on Linux" β€” read those words twice, they are NOT decorative.

πŸ’– NAME πŸ’–

termios.h β€” define values for termios


πŸŽ€ SYNOPSIS πŸŽ€

#include <termios.h>

🌈 DESCRIPTION 🌈

The <termios.h> header shall contain the definitions used by the terminal I/O interfaces (see Chapter 11, General Terminal Interface for the structures and names defined).


πŸ¦‹ The termios Structure πŸ¦‹

The <termios.h> header shall define the following data types through typedef:

  • cc_t β€” Used for terminal special characters.
  • speed_t β€” Used for terminal baud rates.
  • tcflag_t β€” Used for terminal modes.

The above types shall be all unsigned integer types.

The implementation shall support one or more programming environments in which the widths of cc_t, speed_t, and tcflag_t are no greater than the width of type long. The names of these programming environments can be obtained using the confstr() function or the getconf utility.

The <termios.h> header shall define the termios structure, which shall include at least the following members:

tcflag_t  c_iflag     Input modes.
tcflag_t  c_oflag     Output modes.
tcflag_t  c_cflag     Control modes.
tcflag_t  c_lflag     Local modes.
cc_t      c_cc[NCCS]  Control characters.

The <termios.h> header shall define the following symbolic constant:

  • NCCS β€” Size of the array c_cc for control characters.

The <termios.h> header shall define the following symbolic constants for use as subscripts for the array c_cc. The table is serving two modes at once, so here's the whole vibe laid out flat πŸ’… β€” first the ones you use in canonical mode, then the ones in non-canonical mode, then the tea:

  • VEOF β€” Canonical Mode. EOF character.
  • VEOL β€” Canonical Mode. EOL character.
  • VERASE β€” Canonical Mode. ERASE character.
  • VINTR β€” Canonical Mode and Non-Canonical Mode. INTR character.
  • VKILL β€” Canonical Mode. KILL character.
  • VMIN β€” Non-Canonical Mode. MIN value.
  • VQUIT β€” Canonical Mode and Non-Canonical Mode. QUIT character.
  • VSTART β€” Canonical Mode and Non-Canonical Mode. START character.
  • VSTOP β€” Canonical Mode and Non-Canonical Mode. STOP character.
  • VSUSP β€” Canonical Mode and Non-Canonical Mode. SUSP character.
  • VTIME β€” Non-Canonical Mode. TIME value.

The subscript values shall be suitable for use in #if preprocessing directives and shall be distinct, except that the VMIN and VTIME subscripts may have the same values as the VEOF and VEOL subscripts, respectively.


⭐ Input Modes ⭐

The <termios.h> header shall define the following symbolic constants for use as flags in the c_iflag field. The c_iflag field describes the basic terminal input control.

  • BRKINT β€” Signal interrupt on break.
  • ICRNL β€” Map CR to NL on input.
  • IGNBRK β€” Ignore break condition.
  • IGNCR β€” Ignore CR.
  • IGNPAR β€” Ignore characters with parity errors.
  • INLCR β€” Map NL to CR on input.
  • INPCK β€” Enable input parity check.
  • ISTRIP β€” Strip character.
  • IXANY β€” Enable any character to restart output.
  • IXOFF β€” Enable start/stop input control.
  • IXON β€” Enable start/stop output control.
  • PARMRK β€” Mark parity errors.

πŸ’œ Output Modes πŸ’œ

The <termios.h> header shall define the following symbolic constants for use as flags in the c_oflag field. The c_oflag field specifies the system treatment of output.

  • OPOST β€” Post-process output.
  • ONLCR β€” Map NL to CR-NL on output.
  • OCRNL β€” Map CR to NL on output.
  • ONOCR β€” No CR output at column 0.
  • ONLRET β€” NL performs CR function.
  • OFDEL β€” Fill is DEL.
  • OFILL β€” Use fill characters for delay.
  • NLDLY β€” Select newline delays:
    • NL0 β€” Newline type 0.
    • NL1 β€” Newline type 1.
  • CRDLY β€” Select carriage-return delays:
    • CR0 β€” Carriage-return delay type 0.
    • CR1 β€” Carriage-return delay type 1.
    • CR2 β€” Carriage-return delay type 2.
    • CR3 β€” Carriage-return delay type 3.
  • TABDLY β€” Select horizontal-tab delays:
    • TAB0 β€” Horizontal-tab delay type 0.
    • TAB1 β€” Horizontal-tab delay type 1.
    • TAB2 β€” Horizontal-tab delay type 2.
    • TAB3 β€” Expand tabs to spaces.
  • BSDLY β€” Select backspace delays:
    • BS0 β€” Backspace-delay type 0.
    • BS1 β€” Backspace-delay type 1.
  • VTDLY β€” Select vertical-tab delays:
    • VT0 β€” Vertical-tab delay type 0.
    • VT1 β€” Vertical-tab delay type 1.
  • FFDLY β€” Select form-feed delays:
    • FF0 β€” Form-feed delay type 0.
    • FF1 β€” Form-feed delay type 1.

🧚 Baud Rate Selection 🧚

The <termios.h> header shall define the following symbolic constants for use as values of objects of type speed_t.

The input and output baud rates are stored in the termios structure. These are the valid values for objects of type speed_t. Not all baud rates need be supported by the underlying hardware.

πŸ™ˆ read that last sentence again before you come for your hardware, bestie. it's not obligated to serve every single one of these.
  • B0 β€” Hang up
  • B50 β€” 50 baud
  • B75 β€” 75 baud
  • B110 β€” 110 baud
  • B134 β€” 134.5 baud
  • B150 β€” 150 baud
  • B200 β€” 200 baud
  • B300 β€” 300 baud
  • B600 β€” 600 baud
  • B1200 β€” 1200 baud
  • B1800 β€” 1800 baud
  • B2400 β€” 2400 baud
  • B4800 β€” 4800 baud
  • B9600 β€” 9600 baud
  • B19200 β€” 19200 baud
  • B38400 β€” 38400 baud

πŸ‘‘ Control Modes πŸ‘‘

The <termios.h> header shall define the following symbolic constants for use as flags in the c_cflag field. The c_cflag field describes the hardware control of the terminal; not all values specified are required to be supported by the underlying hardware.

  • CSIZE β€” Character size:
    • CS5 β€” 5 bits
    • CS6 β€” 6 bits
    • CS7 β€” 7 bits
    • CS8 β€” 8 bits
  • CSTOPB β€” Send two stop bits, else one.
  • CREAD β€” Enable receiver.
  • PARENB β€” Parity enable.
  • PARODD β€” Odd parity, else even.
  • HUPCL β€” Hang up on last close.
  • CLOCAL β€” Ignore modem status lines.

The implementation shall support the functionality associated with the symbols CS7, CS8, CSTOPB, PARODD, and PARENB.


πŸ“ Local Modes πŸ“

The <termios.h> header shall define the following symbolic constants for use as flags in the c_lflag field. The c_lflag field of the argument structure is used to control various terminal functions.

  • ECHO β€” Enable echo.
  • ECHOE β€” Echo erase character as error-correcting backspace.
  • ECHOK β€” Echo KILL.
  • ECHONL β€” Echo NL.
  • ICANON β€” Canonical input (erase and kill processing).
  • IEXTEN β€” Enable extended input character processing.
  • ISIG β€” Enable signals.
  • NOFLSH β€” Disable flush after interrupt or quit.
  • TOSTOP β€” Send SIGTTOU for background output.

πŸ’… Attribute Selection πŸ’…

The <termios.h> header shall define the following symbolic constants for use with tcsetattr():

  • TCSANOW β€” Change attributes immediately.
  • TCSADRAIN β€” Change attributes when output has drained.
  • TCSAFLUSH β€” Change attributes when output has drained; also flush pending input.

🌸 Line Control 🌸

The <termios.h> header shall define the following symbolic constants for use with tcflush():

  • TCIFLUSH β€” Flush pending input.
  • TCIOFLUSH β€” Flush both pending input and untransmitted output.
  • TCOFLUSH β€” Flush untransmitted output.

The <termios.h> header shall define the following symbolic constants for use with tcflow():

  • TCIOFF β€” Transmit a STOP character, intended to suspend input data.
  • TCION β€” Transmit a START character, intended to restart input data.
  • TCOOFF β€” Suspend output.
  • TCOON β€” Restart output.

The <termios.h> header shall define the pid_t type as described in <sys/types.h>.

The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.

speed_t cfgetispeed(const struct termios *);
speed_t cfgetospeed(const struct termios *);
int     cfsetispeed(struct termios *, speed_t);
int     cfsetospeed(struct termios *, speed_t);
int     tcdrain(int);
int     tcflow(int, int);
int     tcflush(int, int);
int     tcgetattr(int, struct termios *);
pid_t   tcgetsid(int);
int     tcsendbreak(int, int);
int     tcsetattr(int, int, const struct termios *);

The following sections are informative.


🫢 APPLICATION USAGE 🫢

The following names are reserved for XSI-conformant systems to use as an extension to the above; therefore strictly conforming applications shall not use them:

CBAUD      EXTB       VDSUSP
DEFECHO    FLUSHO     VLNEXT
ECHOCTL    LOBLK      VREPRINT
ECHOKE     PENDIN     VSTATUS
ECHOPRT    SWTCH      VWERASE
EXTA       VDISCARD
😭 bestie do NOT touch these names. they're reserved. that's the whole point. hands off the keyboard.

πŸ’€ RATIONALE πŸ’€

None.


🌈 FUTURE DIRECTIONS 🌈

None.


πŸ”₯ SEE ALSO πŸ”₯

  • <sys_types.h>
  • The System Interfaces volume of POSIX.1‐2017, cfgetispeed(), cfgetospeed(), cfsetispeed(), cfsetospeed(), confstr(), tcdrain(), tcflow(), tcflush(), tcgetattr(), tcgetsid(), tcsendbreak(), tcsetattr()
  • The Shell and Utilities volume of POSIX.1‐2017, Chapter 11, General Terminal Interface, getconf

Okay bestie, legal era incoming, but stay with me because this part actually matters. πŸ’…

Some of this text is reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. Periodt. ✨

🚨 And here's the part you don't skip, bestie: if this version and the original IEEE and The Open Group Standard ever disagree about anything, the original IEEE and The Open Group Standard is the referee document. Like, it wins. No debate, no discourse, the original ate and it's the final word. 😀

The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . 🌐


And listen β€” any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. 😭 Not the standard's fault, not your fave's fault, it's the conversion's fault, fr fr. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html . 🫢


πŸŽ€ that's the whole page, bestie πŸŽ€

We did it. Every flag, every struct, every little nuance β€” all of it. Slay. πŸ’–

Oh and for the record, this came to you courtesy of IEEE/The Open Group, dated 2017, and it lives under the name termios.h(0P). Iconic lineage honestly. πŸ‘‘

Go forth and configure your terminals, main character. πŸŒΈπŸ¦‹πŸ’œ

πŸ“¦ where this page comes from