Debian Codegraph @

upstream/debian-unstable/man3/tcgetpgrp.3

raw
1 '\" t
2 .\" Copyright 2002, Andries E. Brouwer <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH tcgetpgrp 3 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 tcgetpgrp, tcsetpgrp \- get and set terminal foreground process group
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ,\~ \-lc )
13 .SH SYNOPSIS
14 .nf
15 .B "#include <unistd.h>"
16 .P
17 .BI "pid_t tcgetpgrp(int " fd );
18 .BI "int tcsetpgrp(int " fd ", pid_t " pgrp );
19 .fi
20 .SH DESCRIPTION
21 The function
22 .BR tcgetpgrp ()
23 returns the process group ID of the foreground process group on the
24 terminal associated to
25 .IR fd ,
26 which must be the controlling terminal of the calling process.
27 .\" The process itself may be a background process.
28 .P
29 The function
30 .BR tcsetpgrp ()
31 makes the process group with process group ID
32 .I pgrp
33 the foreground process group on the terminal associated to
34 .IR fd ,
35 which must be the controlling terminal of the calling process,
36 and still be associated with its session.
37 Moreover,
38 .I pgrp
39 must be a (nonempty) process group belonging to
40 the same session as the calling process.
41 .P
42 If
43 .BR tcsetpgrp ()
44 is called by a member of a background process group in its session,
45 and the calling process is not blocking or ignoring
46 .BR SIGTTOU ,
47 a
48 .B SIGTTOU
49 signal is sent to all members of this background process group.
50 .SH RETURN VALUE
51 When
52 .I fd
53 refers to the controlling terminal of the calling process,
54 the function
55 .BR tcgetpgrp ()
56 will return the foreground process group ID of that terminal
57 if there is one, and some value larger than 1 that is not
58 presently a process group ID otherwise.
59 When
60 .I fd
61 does not refer to the controlling terminal of the calling process,
62 \-1 is returned, and
63 .I errno
64 is set to indicate the error.
65 .P
66 When successful,
67 .BR tcsetpgrp ()
68 returns 0.
69 Otherwise, it returns \-1, and
70 .I errno
71 is set to indicate the error.
72 .SH ERRORS
73 .TP
74 .B EBADF
75 .I fd
76 is not a valid file descriptor.
77 .TP
78 .B EINVAL
79 .I pgrp
80 has an unsupported value.
81 .TP
82 .B ENOTTY
83 The calling process does not have a controlling terminal, or
84 it has one but it is not described by
85 .IR fd ,
86 or, for
87 .BR tcsetpgrp (),
88 this controlling terminal is no longer associated with the session
89 of the calling process.
90 .TP
91 .B EPERM
92 .I pgrp
93 has a supported value, but is not the process group ID of a
94 process in the same session as the calling process.
95 .SH ATTRIBUTES
96 For an explanation of the terms used in this section, see
97 .BR attributes (7).
98 .TS
99 allbox;
100 lbx lb lb
101 l l l.
102 Interface Attribute Value
103 T{
104 .na
105 .nh
106 .BR tcgetpgrp (),
107 .BR tcsetpgrp ()
108 T} Thread safety MT-Safe
109 .TE
110 .SH VERSIONS
111 These functions are implemented via the
112 .B TIOCGPGRP
113 and
114 .B TIOCSPGRP
115 ioctls.
116 .SH STANDARDS
117 POSIX.1-2008.
118 .SH HISTORY
119 POSIX.1-2001.
120 .P
121 The ioctls appeared in 4.2BSD.
122 The functions are POSIX inventions.
123 .SH SEE ALSO
124 .BR setpgid (2),
125 .BR setsid (2),
126 .BR credentials (7)