unlockpt(3)

πŸ’– unlockpt(3) β€” the pty-unlocking girlie πŸ’–

okay so bestie, welcome to unlockpt(3) from the Library Functions Manual 🌸 this is a libc function, she's a little legend, and she's here to unlock a pseudoterminal master/slave pair. yes. that's the whole vibe. let's get into it 🫢


✨ NAME ✨

unlockpt β€” unlock a pseudoterminal master/slave pair πŸ”“

πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc) πŸ’…

πŸŽ€ SYNOPSIS πŸŽ€

#define _XOPEN_SOURCE
#include <stdlib.h>

int unlockpt(int fd);

πŸ¦‹ Feature Test Macro Requirements for glibc (see feature_test_macros(7)) πŸ¦‹

unlockpt():

  • Since glibc 2.24:
    • _XOPEN_SOURCE >= 500
  • glibc 2.23 and earlier:
    • _XOPEN_SOURCE

like ok glibc really said "know your macros before you call me" 😭 iconic gatekeeping fr.

🌈 DESCRIPTION 🌈

so the unlockpt() function unlocks the slave pseudoterminal device that corresponds to the master pseudoterminal referred to by the file descriptor fd. that's it, that's the job, she ate and left no crumbs πŸ‘‘

unlockpt() should be called before opening the slave side of a pseudoterminal. order matters bestie, this is not a choose-your-own-adventure situation πŸ’…βœ¨

⭐ RETURN VALUE ⭐

when successful, unlockpt() returns 0. slay πŸ’–

otherwise, it returns -1 and sets errno to indicate the error. not slay 😭

πŸ’€ ERRORS πŸ’€

  • EBADF β€” the fd argument is not a file descriptor open for writing. bestie that fd is NOT valid for this, put it down πŸ™ˆ
  • EINVAL β€” the fd argument is not associated with a master pseudoterminal. wrong terminal, wrong vibe, vibe check failed fr fr πŸ’€

πŸ‘‘ ATTRIBUTES πŸ‘‘

for an explanation of the terms used in this section, see attributes(7).

  • Interface: unlockpt()
  • Attribute: Thread safety
  • Value: MT-Safe

so yes she's MT-Safe, she can hang with multiple threads, no drama, no beef, queen behavior ✨

🌸 STANDARDS 🌸

POSIX.1-2008. certified, official, on the list πŸ’…

🧚 HISTORY 🧚

glibc 2.1. POSIX.1-2001. she's been around a minute, lowkey a legacy icon πŸ‘‘

πŸ”₯ SEE ALSO πŸ”₯

grantpt(3), posix_openpt(3), ptsname(3), pts(4), pty(7)


🫢 reminder: call unlockpt() before opening the slave side. skipping that step is giving "I didn't read the instructions" energy and you WILL be getting that -1 πŸ’€

k love u bye, this was Linux man-pages 6.20, dated 2025-09-21 β€” and that's the whole page bestie, no cap πŸŒˆπŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ 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