getpt(3)
β¨ getpt β open a new pseudoterminal master β¨
okay bestie, we're in the library functions manual (getpt(3)) and this one is short but it's got LORE, so sit with me π
πΈ NAME πΈ
getpt β open a new pseudoterminal master
like, it gets you a pty. that's the whole job. that's the girlbossery.
π LIBRARY π
Standard C library (libc, -lc)
π SYNOPSIS π
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <stdlib.h>
int getpt(void);
heads up: that#define _GNU_SOURCEis not optional, bestie. no define, no function. seefeature_test_macros(7)for the receipts.
π¦ DESCRIPTION π¦
so getpt() opens a brand new pseudoterminal device and hands you back a file descriptor that refers to that device. that's it, that's the function π«Ά
it is equivalent to opening the pseudoterminal multiplexer device like this:
open("/dev/ptmx", O_RDWR);
on Linux systems β but here's the plot twist β the pseudoterminal multiplexer device is located elsewhere on some systems that use the GNU C library. so like, don't be out here hardcoding assumptions, iykyk π§
π RETURN VALUE π
- on a good day?
getpt()returns an open file descriptor. slay. β¨ - on a bad day? it returns
-1and setserrnoto tell you what went wrong. not slay, but at least it's honest π
π ERRORS π
getpt() can fail with various errors described in open(2). go read that one, it's the whole buffet.
π ATTRIBUTES π
for an explanation of the terms used in this section, see attributes(7).
- Interface:
getpt() - Attribute: Thread safety
- Value:
MT-Safe
translation: it's thread safe, bestie, go wild (responsibly)
β VERSIONS β
use posix_openpt(3) instead.
fr fr. this one's giving deprecated energy.getpt()is lowkey the older sibling andposix_openpt(3)is the one that ate. π
π STANDARDS π
GNU.
π HISTORY π
glibc 2.1.
so it's been around a minute. respect the elders π«‘
π SEE ALSO π
and that's the page, bestie!! π this was pulled straight from Linux man-pages 6.20, dated 2025-12-26, and you just read getpt(3). go forth and open your pseudoterminals responsibly β¨π π¦
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms