malloc.3: ffix
[man-pages.git] / man3 / tcgetpgrp.3
blobe14c594cc734d2f416bb0c1529fcd1d7feeb819e
1 .\" Copyright (C) 2002 Andries Brouwer <aeb@cwi.nl>
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .TH TCGETPGRP 3 2021-03-22 "GNU" "Linux Programmer's Manual"
26 .SH NAME
27 tcgetpgrp, tcsetpgrp \- get and set terminal foreground process group
28 .SH SYNOPSIS
29 .nf
30 .B "#include <unistd.h>"
31 .PP
32 .BI "pid_t tcgetpgrp(int " fd );
33 .BI "int tcsetpgrp(int " fd ", pid_t " pgrp );
34 .fi
35 .SH DESCRIPTION
36 The function
37 .BR tcgetpgrp ()
38 returns the process group ID of the foreground process group on the
39 terminal associated to
40 .IR fd ,
41 which must be the controlling terminal of the calling process.
42 .\" The process itself may be a background process.
43 .PP
44 The function
45 .BR tcsetpgrp ()
46 makes the process group with process group ID
47 .I pgrp
48 the foreground process group on the terminal associated to
49 .IR fd ,
50 which must be the controlling terminal of the calling process,
51 and still be associated with its session.
52 Moreover,
53 .I pgrp
54 must be a (nonempty) process group belonging to
55 the same session as the calling process.
56 .PP
58 .BR tcsetpgrp ()
59 is called by a member of a background process group in its session,
60 and the calling process is not blocking or ignoring
61 .BR SIGTTOU ,
63 .B SIGTTOU
64 signal is sent to all members of this background process group.
65 .SH RETURN VALUE
66 When
67 .I fd
68 refers to the controlling terminal of the calling process,
69 the function
70 .BR tcgetpgrp ()
71 will return the foreground process group ID of that terminal
72 if there is one, and some value larger than 1 that is not
73 presently a process group ID otherwise.
74 When
75 .I fd
76 does not refer to the controlling terminal of the calling process,
77 \-1 is returned, and
78 .I errno
79 is set to indicate the error.
80 .PP
81 When successful,
82 .BR tcsetpgrp ()
83 returns 0.
84 Otherwise, it returns \-1, and
85 .I errno
86 is set to indicate the error.
87 .SH ERRORS
88 .TP
89 .B EBADF
90 .I fd
91 is not a valid file descriptor.
92 .TP
93 .B EINVAL
94 .I pgrp
95 has an unsupported value.
96 .TP
97 .B ENOTTY
98 The calling process does not have a controlling terminal, or
99 it has one but it is not described by
100 .IR fd ,
101 or, for
102 .BR tcsetpgrp (),
103 this controlling terminal is no longer associated with the session
104 of the calling process.
106 .B EPERM
107 .I pgrp
108 has a supported value, but is not the process group ID of a
109 process in the same session as the calling process.
110 .SH ATTRIBUTES
111 For an explanation of the terms used in this section, see
112 .BR attributes (7).
113 .ad l
116 allbox;
117 lbx lb lb
118 l l l.
119 Interface       Attribute       Value
121 .BR tcgetpgrp (),
122 .BR tcsetpgrp ()
123 T}      Thread safety   MT-Safe
127 .sp 1
128 .SH CONFORMING TO
129 POSIX.1-2001, POSIX.1-2008.
130 .SH NOTES
131 These functions are implemented via the
132 .B TIOCGPGRP
134 .B TIOCSPGRP
135 ioctls.
136 .SS History
137 The ioctls appeared in 4.2BSD.
138 The functions are POSIX inventions.
139 .SH SEE ALSO
140 .BR setpgid (2),
141 .BR setsid (2),
142 .BR credentials (7)