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 theCAP_SYS_ADMINpass. 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
- Copyright 2002, Walter Harms <walter.harms@informatik.uni-oldenburg.de>
- Copyright 2002, Andries E. Brouwer <aeb@cwi.nl>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms