{
    "mode": "man",
    "parameter": "pty",
    "section": "7",
    "url": "https://www.chedong.com/phpMan.php/man/pty/7/json",
    "generated": "2026-09-20T03:11:36Z",
    "sections": {
        "NAME": {
            "content": "pty - pseudoterminal interfaces\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "A  pseudoterminal  (sometimes  abbreviated \"pty\") is a pair of virtual character devices that\nprovide a bidirectional communication channel.  One end of the channel is called the  master;\nthe other end is called the slave.\n\nThe slave end of the pseudoterminal provides an interface that behaves exactly like a classi‐\ncal  terminal.   A process that expects to be connected to a terminal, can open the slave end\nof a pseudoterminal and then be driven by a program that has opened the master end.  Anything\nthat is written on the master end is provided to the process on the slave end  as  though  it\nwas  input  typed  on a terminal.  For example, writing the interrupt character (usually con‐\ntrol-C) to the master device would cause an interrupt signal (SIGINT) to be generated for the\nforeground process group that is connected to the slave.  Conversely, anything that is  writ‐\nten  to  the  slave end of the pseudoterminal can be read by the process that is connected to\nthe master end.\n\nData flow between master and slave is handled asynchronously, much  like  data  flow  with  a\nphysical  terminal.   Data written to the slave will be available at the master promptly, but\nmay not be available immediately.  Similarly, there may be a small processing delay between a\nwrite to the master, and the effect being visible at the slave.\n\nHistorically, two pseudoterminal APIs have evolved: BSD and System V.  SUSv1  standardized  a\npseudoterminal API based on the System V API, and this API should be employed in all new pro‐\ngrams that use pseudoterminals.\n\nLinux  provides  both BSD-style and (standardized) System V-style pseudoterminals.  System V-\nstyle terminals are commonly called UNIX 98 pseudoterminals on Linux systems.\n\nSince Linux 2.6.4, BSD-style pseudoterminals are considered deprecated: support can  be  dis‐\nabled  when  building  the kernel by disabling the CONFIGLEGACYPTYS option.  (Starting with\nLinux 2.6.30, that option is disabled by default in the mainline kernel.)  UNIX 98 pseudoter‐\nminals should be used in new applications.\n",
            "subsections": [
                {
                    "name": "UNIX 98 pseudoterminals",
                    "content": "An unused UNIX 98 pseudoterminal master is opened by calling posixopenpt(3).  (This function\nopens the master clone device, /dev/ptmx; see pts(4).)  After performing any program-specific\ninitializations, changing the ownership and permissions of the slave device using grantpt(3),\nand unlocking the slave using unlockpt(3)), the corresponding slave device can be  opened  by\npassing the name returned by ptsname(3) in a call to open(2).\n\nThe  Linux  kernel imposes a limit on the number of available UNIX 98 pseudoterminals.  Up to\nand including Linux 2.6.3,  this  limit  is  configured  at  kernel  compilation  time  (CON‐\nFIGUNIX98PTYS),  and  the permitted number of pseudoterminals can be up to 2048, with a de‐\nfault  setting  of  256.   Since  Linux  2.6.4,  the  limit  is  dynamically  adjustable  via\n/proc/sys/kernel/pty/max,  and  a  corresponding file, /proc/sys/kernel/pty/nr, indicates how\nmany pseudoterminals are currently in use.  For further  details  on  these  two  files,  see\nproc(5).\n"
                },
                {
                    "name": "BSD pseudoterminals",
                    "content": "BSD-style pseudoterminals are provided as precreated pairs, with names of the form /dev/ptyXY\n(master)  and /dev/ttyXY (slave), where X is a letter from the 16-character set [p-za-e], and\nY is a letter from the 16-character set [0-9a-f].  (The precise range of letters in these two\nsets varies across UNIX implementations.)  For example, /dev/ptyp1 and /dev/ttyp1  constitute\na  BSD  pseudoterminal  pair.   A  process  finds  an unused pseudoterminal pair by trying to\nopen(2) each pseudoterminal master until an open succeeds.  The corresponding  pseudoterminal\nslave (substitute \"tty\" for \"pty\" in the name of the master) can then be opened.\n"
                }
            ]
        },
        "FILES": {
            "content": "/dev/ptmx\nUNIX 98 master clone device\n\n/dev/pts/*\nUNIX 98 slave devices\n\n/dev/pty[p-za-e][0-9a-f]\nBSD master devices\n\n/dev/tty[p-za-e][0-9a-f]\nBSD slave devices\n",
            "subsections": []
        },
        "NOTES": {
            "content": "Pseudoterminals  are  used by applications such as network login services (ssh(1), rlogin(1),\ntelnet(1)), terminal emulators such as xterm(1), script(1), screen(1), tmux(1),  unbuffer(1),\nand expect(1).\n\nA  description of the TIOCPKT ioctl(2), which controls packet mode operation, can be found in\nioctltty(2).\n\nThe BSD ioctl(2) operations TIOCSTOP, TIOCSTART, TIOCUCNTL, and TIOCREMOTE have not been  im‐\nplemented under Linux.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "ioctltty(2), select(2), setsid(2), forkpty(3), openpty(3), termios(3), pts(4), tty(4)\n\nLinux man-pages 6.7                          2023-11-19                                       pty(7)",
            "subsections": []
        }
    },
    "summary": "pty - pseudoterminal interfaces",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "ioctltty",
            "section": "2",
            "url": "https://www.chedong.com/phpMan.php/man/ioctltty/2/json"
        },
        {
            "name": "select",
            "section": "2",
            "url": "https://www.chedong.com/phpMan.php/man/select/2/json"
        },
        {
            "name": "setsid",
            "section": "2",
            "url": "https://www.chedong.com/phpMan.php/man/setsid/2/json"
        },
        {
            "name": "forkpty",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/forkpty/3/json"
        },
        {
            "name": "openpty",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/openpty/3/json"
        },
        {
            "name": "termios",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/termios/3/json"
        },
        {
            "name": "pts",
            "section": "4",
            "url": "https://www.chedong.com/phpMan.php/man/pts/4/json"
        },
        {
            "name": "tty",
            "section": "4",
            "url": "https://www.chedong.com/phpMan.php/man/tty/4/json"
        }
    ]
}