Debian Codegraph @

upstream/debian-unstable/man2/TIOCSCTTY.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 TIOCSCTTY 2const 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 TIOCSCTTY,
10 TIOCNOTTY
11 \-
12 controlling the terminal
13 .SH LIBRARY
14 Standard C library
15 .RI ( libc ,\~ \-lc )
16 .SH SYNOPSIS
17 .nf
18 .BR "#include <asm/termbits.h>" " /* Definition of " TIOC*TTY " constants */"
19 .B #include <sys/ioctl.h>
20 .P
21 .BI "int ioctl(int " fd ", TIOCSCTTY, int " arg );
22 .BI "int ioctl(int " fd ", TIOCNOTTY);"
23 .fi
24 .SH DESCRIPTION
25 .TP
26 .B TIOCSCTTY
27 Make the given terminal the controlling terminal of the calling process.
28 The calling process must be a session leader and not have a
29 controlling terminal already.
30 For this case,
31 .I arg
32 should be specified as zero.
33 .IP
34 If this terminal is already the controlling terminal
35 of a different session group, then the ioctl fails with
36 .BR EPERM ,
37 unless the caller has the
38 .B CAP_SYS_ADMIN
39 capability and
40 .I arg
41 equals 1, in which case the terminal is stolen, and all processes that had
42 it as controlling terminal lose it.
43 .TP
44 .B TIOCNOTTY
45 If the given terminal was the controlling terminal of the calling process,
46 give up this controlling terminal.
47 If the process was session leader,
48 then send
49 .B SIGHUP
50 and
51 .B SIGCONT
52 to the foreground process group
53 and all processes in the current session lose their controlling terminal.
54 .SH RETURN VALUE
55 On success,
56 0 is returned.
57 On error,
58 \-1 is returned, and
59 .I errno
60 is set to indicate the error.
61 .SH ERRORS
62 .TP
63 .B EPERM
64 Insufficient permission.
65 .SH SEE ALSO
66 .BR ioctl (2),
67 .BR ioctl_tty (2)