Debian Codegraph @

upstream/debian-unstable/man2/TIOCCONS.2const

raw
1 .\" Copyright 2002, Walter Harms <[email protected]>
2 .\" Copyright 2002, Andries E. Brouwer <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: GPL-1.0-or-later
6 .\"
7 .TH TIOCCONS 2const 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 TIOCCONS
10 \-
11 redirecting console output
12 .SH LIBRARY
13 Standard C library
14 .RI ( libc ,\~ \-lc )
15 .SH SYNOPSIS
16 .nf
17 .BR "#include <asm/termbits.h>" " /* Definition of " TIOCCONS " */"
18 .B #include <sys/ioctl.h>
19 .P
20 .BI "int ioctl(int " fd ", TIOCCONS);"
21 .fi
22 .SH DESCRIPTION
23 Redirect output that would have gone to
24 .I /dev/console
25 or
26 .I /dev/tty0
27 to the given terminal.
28 If that was a pseudoterminal master, send it to the slave.
29 .P
30 Only a process with the
31 .B CAP_SYS_ADMIN
32 capability may do this.
33 .P
34 If output was redirected already, then
35 .B EBUSY
36 is returned,
37 but redirection can be stopped by using this ioctl with
38 .I fd
39 pointing at
40 .I /dev/console
41 or
42 .IR /dev/tty0 .
43 .SH RETURN VALUE
44 On success,
45 0 is returned.
46 On error,
47 \-1 is returned, and
48 .I errno
49 is set to indicate the error.
50 .SH ERRORS
51 .TP
52 .B EBUSY
53 Output was redirected already.
54 .TP
55 .B EPERM
56 Insufficient permission.
57 .SH HISTORY
58 Before Linux 2.6.10,
59 anybody can do this as long as the output was not redirected yet;
60 .B CAP_SYS_ADMIN
61 was not necessary.
62 .SH SEE ALSO
63 .BR ioctl (2),
64 .BR ioctl_tty (2)