]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/tcgetpgrp.3
Automated unformatting of parentheses using unformat_parens.sh
[thirdparty/man-pages.git] / man3 / tcgetpgrp.3
1 .\" Copyright (C) 2002 Andries Brouwer <aeb@cwi.nl>
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .TH TCGETPGRP 3 2003-01-28 "POSIX" "Linux Programmer's Manual"
24 .SH NAME
25 tcgetpgrp, tcsetpgrp \- get and set terminal foreground process group
26 .SH SYNOPSIS
27 .sp
28 .BR "#include <unistd.h>"
29 .sp
30 .BI "pid_t tcgetpgrp(int " fd );
31 .sp
32 .BI "int tcsetpgrp(int " fd ", pid_t " pgrp );
33 .SH DESCRIPTION
34 The function
35 .BR tcgetpgrp ()
36 returns the process group ID of the foreground process group on the
37 terminal associated to
38 .IR fd ,
39 which must be the controlling terminal of the calling process.
40 .\" The process itself may be a background process.
41 .LP
42 The function
43 .BR tcsetpgrp ()
44 makes the process group with process group ID \fIpgrp\fP
45 the foreground process group on the terminal associated to
46 .IR fd ,
47 which must be the controlling terminal of the calling process,
48 and still be associated with its session.
49 Moreover, \fIpgrp\fP must be a (nonempty) process group belonging to
50 the same session as the calling process.
51 .LP
52 If
53 .BR tcsetpgrp ()
54 is called by a member of a background process group in its session,
55 and the calling process is not blocking or ignoring SIGTTOU,
56 a SIGTTOU signal is sent to all members of this background process group.
57 .SH "RETURN VALUE"
58 When
59 .I fd
60 refers to the controlling terminal of the calling process,
61 the function
62 .BR tcgetpgrp ()
63 will return the foreground process group ID of that terminal
64 if there is one, and some value larger than 1 that is not
65 presently a process group ID otherwise.
66 When
67 .I fd
68 does not refer to the controlling terminal of the calling process,
69 \-1 is returned, and
70 .I errno
71 is set appropriately.
72 .LP
73 When successful,
74 .BR tcsetpgrp ()
75 returns 0. Otherwise, it returns \-1, and
76 .I errno
77 is set appropriately.
78 .SH ERRORS
79 .TP
80 .B EBADF
81 .I fd
82 is not a valid file descriptor.
83 .TP
84 .B EINVAL
85 .I pgrp
86 has an unsupported value.
87 .TP
88 .B ENOTTY
89 The calling process does not have a controlling terminal, or
90 it has one but it is not described by
91 .IR fd ,
92 or, for
93 .BR tcsetpgrp (),
94 this controlling terminal is no longer associated with the session
95 of the calling process.
96 .TP
97 .B EPERM
98 .I pgrp
99 has a supported value, but is not the process group ID of a
100 process in the same session as the calling process.
101 .SH NOTES
102 These functions are implemented via the TIOCGPGRP and
103 TIOCSPGRP ioctls.
104 .SH HISTORY
105 These ioctls appeared in 4.2 BSD. The functions are POSIX inventions.
106 .SH "CONFORMS TO"
107 POSIX.1
108 .SH "SEE ALSO"
109 .BR setpgid (2),
110 .BR setsid (2)