TIOCCONS(2const)

✨ NAME ✨

TIOCCONS β€” redirecting console output πŸ’– (it's a 2const page bestie, we love a const)


πŸ“š LIBRARY

Standard C library (libc, -lc) 🫢


🌸 SYNOPSIS

#include <asm/termbits.h>  /* Definition of TIOCCONS */
#include <sys/ioctl.h>

int ioctl(int fd, TIOCCONS);

πŸ‘‘ DESCRIPTION

Okay so picture this: output is out here living its life, headed straight for /dev/console or /dev/tty0, and you're like "no babe, wrong direction." That's what this does β€” it redirects output that would have gone to /dev/console or /dev/tty0 to the given terminal. And if that terminal was a pseudoterminal master? Then the output gets sent to the slave instead. Slay. ✨

But here's the gatekeeping part: only a process with the CAP_SYS_ADMIN capability may do this. No cap, no redirect. πŸ’…

And if output was redirected already, then EBUSY is returned. BUT β€” plot twist β€” redirection can be stopped by using this ioctl with fd pointing at /dev/console or /dev/tty0. So you're not stuck, bestie, there's a way out. πŸ¦‹

⚠️ Lowkey important: remember that CAP_SYS_ADMIN requirement, because it was NOT always a thing. Keep reading. πŸ‘€

πŸŽ€ RETURN VALUE

On success, 0 is returned. Iconic, perfect, no notes. 🌟

On error, -1 is returned, and errno is set to indicate the error. Rude, but informative. 😭


πŸ’€ ERRORS

  • EBUSY β€” Output was redirected already. Somebody got there first, the console is taken, it's giving occupied. 🚫
  • EPERM β€” Insufficient permission. You simply do not have the CAP_SYS_ADMIN pass. Not you, bestie. πŸ™ˆ

πŸ•°οΈ HISTORY

Before Linux 2.6.10, anybody can do this as long as the output was not redirected yet; CAP_SYS_ADMIN was not necessary. Wild times. The old days were lawless fr fr. πŸ’€βœ¨


πŸ”— SEE ALSO


And that's the whole page, bestie β€” go redirect some console output responsibly. This was TIOCCONS(2const) from Linux man-pages 6.20, dated 2026-02-08. Mwah, ily, go read ioctl_tty(2) next. πŸ’–πŸŽ€πŸ¦‹

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