]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (C) 2002 Andries Brouwer <aeb@cwi.nl> |
2 | .\" | |
93015253 | 3 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
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. | |
c13182ef | 12 | .\" |
fea681da MK |
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. | |
c13182ef | 20 | .\" |
fea681da MK |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
fea681da | 24 | .\" |
460495ca | 25 | .TH TCGETPGRP 3 2015-08-08 "GNU" "Linux Programmer's Manual" |
fea681da MK |
26 | .SH NAME |
27 | tcgetpgrp, tcsetpgrp \- get and set terminal foreground process group | |
28 | .SH SYNOPSIS | |
0daa9e92 | 29 | .B "#include <unistd.h>" |
68e4db0a | 30 | .PP |
fea681da | 31 | .BI "pid_t tcgetpgrp(int " fd ); |
68e4db0a | 32 | .PP |
fea681da MK |
33 | .BI "int tcsetpgrp(int " fd ", pid_t " pgrp ); |
34 | .SH DESCRIPTION | |
35 | The function | |
63aa9df0 | 36 | .BR tcgetpgrp () |
fea681da MK |
37 | returns the process group ID of the foreground process group on the |
38 | terminal associated to | |
39 | .IR fd , | |
40 | which must be the controlling terminal of the calling process. | |
41 | .\" The process itself may be a background process. | |
dd3568a1 | 42 | .PP |
fea681da | 43 | The function |
63aa9df0 | 44 | .BR tcsetpgrp () |
c6fa0841 MK |
45 | makes the process group with process group ID |
46 | .I pgrp | |
fea681da MK |
47 | the foreground process group on the terminal associated to |
48 | .IR fd , | |
49 | which must be the controlling terminal of the calling process, | |
50 | and still be associated with its session. | |
c6fa0841 MK |
51 | Moreover, |
52 | .I pgrp | |
53 | must be a (nonempty) process group belonging to | |
fea681da | 54 | the same session as the calling process. |
dd3568a1 | 55 | .PP |
fea681da | 56 | If |
63aa9df0 | 57 | .BR tcsetpgrp () |
fea681da | 58 | is called by a member of a background process group in its session, |
8bd58774 MK |
59 | and the calling process is not blocking or ignoring |
60 | .BR SIGTTOU , | |
61 | a | |
62 | .B SIGTTOU | |
63 | signal is sent to all members of this background process group. | |
47297adb | 64 | .SH RETURN VALUE |
fea681da MK |
65 | When |
66 | .I fd | |
67 | refers to the controlling terminal of the calling process, | |
68 | the function | |
63aa9df0 | 69 | .BR tcgetpgrp () |
fea681da MK |
70 | will return the foreground process group ID of that terminal |
71 | if there is one, and some value larger than 1 that is not | |
72 | presently a process group ID otherwise. | |
73 | When | |
74 | .I fd | |
75 | does not refer to the controlling terminal of the calling process, | |
76 | \-1 is returned, and | |
77 | .I errno | |
78 | is set appropriately. | |
dd3568a1 | 79 | .PP |
fea681da | 80 | When successful, |
63aa9df0 | 81 | .BR tcsetpgrp () |
677f4766 MK |
82 | returns 0. |
83 | Otherwise, it returns \-1, and | |
fea681da MK |
84 | .I errno |
85 | is set appropriately. | |
86 | .SH ERRORS | |
87 | .TP | |
88 | .B EBADF | |
89 | .I fd | |
90 | is not a valid file descriptor. | |
91 | .TP | |
92 | .B EINVAL | |
93 | .I pgrp | |
94 | has an unsupported value. | |
95 | .TP | |
96 | .B ENOTTY | |
97 | The calling process does not have a controlling terminal, or | |
98 | it has one but it is not described by | |
99 | .IR fd , | |
100 | or, for | |
63aa9df0 | 101 | .BR tcsetpgrp (), |
fea681da MK |
102 | this controlling terminal is no longer associated with the session |
103 | of the calling process. | |
104 | .TP | |
105 | .B EPERM | |
106 | .I pgrp | |
107 | has a supported value, but is not the process group ID of a | |
108 | process in the same session as the calling process. | |
8f9d0619 | 109 | .SH ATTRIBUTES |
5bcd1ce4 PH |
110 | For an explanation of the terms used in this section, see |
111 | .BR attributes (7). | |
112 | .TS | |
113 | allbox; | |
114 | lbw24 lb lb | |
115 | l l l. | |
116 | Interface Attribute Value | |
117 | T{ | |
118 | .BR tcgetpgrp (), | |
8f9d0619 | 119 | .BR tcsetpgrp () |
5bcd1ce4 PH |
120 | T} Thread safety MT-Safe |
121 | .TE | |
47297adb | 122 | .SH CONFORMING TO |
a143c891 | 123 | POSIX.1-2001, POSIX.1-2008. |
fea681da | 124 | .SH NOTES |
097585ed MK |
125 | These functions are implemented via the |
126 | .B TIOCGPGRP | |
127 | and | |
128 | .B TIOCSPGRP | |
129 | ioctls. | |
889829be MK |
130 | .SS History |
131 | The ioctls appeared in 4.2BSD. | |
1c44bd5b | 132 | The functions are POSIX inventions. |
47297adb | 133 | .SH SEE ALSO |
fea681da | 134 | .BR setpgid (2), |
53a1443c MK |
135 | .BR setsid (2), |
136 | .BR credentials (7) |