]>
Commit | Line | Data |
---|---|---|
fea681da MK |
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. | |
c13182ef | 11 | .\" |
fea681da MK |
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. | |
c13182ef | 19 | .\" |
fea681da MK |
20 | .\" Formatted or processed versions of this manual, if unaccompanied by |
21 | .\" the source, must acknowledge the copyright and authors of this work. | |
22 | .\" | |
69962544 | 23 | .TH TCGETPGRP 3 2003-01-28 "GNU" "Linux Programmer's Manual" |
fea681da MK |
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 | |
63aa9df0 | 35 | .BR tcgetpgrp () |
fea681da MK |
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 | |
63aa9df0 | 43 | .BR tcsetpgrp () |
fea681da MK |
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 | |
63aa9df0 | 53 | .BR tcsetpgrp () |
fea681da MK |
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 | |
63aa9df0 | 62 | .BR tcgetpgrp () |
fea681da MK |
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, | |
63aa9df0 | 74 | .BR tcsetpgrp () |
677f4766 MK |
75 | returns 0. |
76 | Otherwise, it returns \-1, and | |
fea681da MK |
77 | .I errno |
78 | is set appropriately. | |
79 | .SH ERRORS | |
80 | .TP | |
81 | .B EBADF | |
82 | .I fd | |
83 | is not a valid file descriptor. | |
84 | .TP | |
85 | .B EINVAL | |
86 | .I pgrp | |
87 | has an unsupported value. | |
88 | .TP | |
89 | .B ENOTTY | |
90 | The calling process does not have a controlling terminal, or | |
91 | it has one but it is not described by | |
92 | .IR fd , | |
93 | or, for | |
63aa9df0 | 94 | .BR tcsetpgrp (), |
fea681da MK |
95 | this controlling terminal is no longer associated with the session |
96 | of the calling process. | |
97 | .TP | |
98 | .B EPERM | |
99 | .I pgrp | |
100 | has a supported value, but is not the process group ID of a | |
101 | process in the same session as the calling process. | |
2b2581ee MK |
102 | .SH "CONFORMING TO" |
103 | POSIX.1-2001. | |
fea681da MK |
104 | .SH NOTES |
105 | These functions are implemented via the TIOCGPGRP and | |
106 | TIOCSPGRP ioctls. | |
889829be MK |
107 | .SS History |
108 | The ioctls appeared in 4.2BSD. | |
1c44bd5b | 109 | The functions are POSIX inventions. |
fea681da MK |
110 | .SH "SEE ALSO" |
111 | .BR setpgid (2), | |
53a1443c MK |
112 | .BR setsid (2), |
113 | .BR credentials (7) |