TIOCEXCL(2const)

πŸ’– TIOCEXCL(2const) πŸ’–

okay bestie, gather round, because today we're talking about TIOCEXCL, TIOCGEXCL, and TIOCNXCL β€” the exclusive-mode trio, living their best lives in section 2const of the manual. no cap, this one's short and sweet and lowkey iconic.


πŸ“š LIBRARY

the standard C library, aka libc, linked in with -lc. she's everywhere, you already know her πŸ’…


✨ SYNOPSIS ✨

#include <asm/termbits.h>  /* Definition of TIOC*XCL constants */
#include <sys/ioctl.h>

int ioctl(int fd, TIOCEXCL);
int ioctl(int fd, TIOCGEXCL, int *argp);
int ioctl(int fd, TIOCNXCL);

see how neat that is? three little ioctl() calls, zero drama πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so each of these is a different flavour of the same vibe, so let me break it down one by one:

  • TIOCEXCL β€” this one puts the terminal into exclusive mode. what does that mean fr fr? it means no further open(2) operations on the terminal are permitted. like, door's closed, we're booked, go home. those open(2) calls fail with EBUSY β€” except for a process that's holding the CAP_SYS_ADMIN capability, because that one's got VIP access, obviously πŸ˜ŒπŸ‘‘
  • TIOCGEXCL β€” this is the gossip check πŸ‘€. if the terminal is currently in exclusive mode, it drops a nonzero value into the location that argp points to. otherwise, it drops a zero into *argp. simple as that, bestie.
  • TIOCNXCL β€” and this one? this one disables exclusive mode. we're opening the doors back up, the party's over, everyone can come in 🫢

🌸 RETURN VALUE 🌸

on success, 0 is returned. slay.

on error, -1 is returned, and errno is set to indicate the error. not slay, but at least you'll know why πŸ’€


πŸ“œ HISTORY πŸ“œ

  • TIOCGEXCL β€” Linux 3.8. so it's been around a minute, she's a seasoned queen ✨

πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, no notes πŸ’– this one came to you straight from Linux man-pages 6.20, dated 2026-02-08 β€” so go forth, lock your terminals, check your exclusive mode, and stan a well-behaved tty interface. periodt πŸŽ€πŸŒˆπŸ§š

πŸ“¦ 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
  • πŸ“œ the page's license: GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms