OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man3 / tcgetpgrp.3
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 2014-01-13 "GNU" "Linux Programmer's Manual"
26 .SH NAME
27 tcgetpgrp, tcsetpgrp \- get and set terminal foreground process group
28 .SH SYNOPSIS
29 .B "#include <unistd.h>"
30 .sp
31 .BI "pid_t tcgetpgrp(int " fd );
32 .sp
33 .BI "int tcsetpgrp(int " fd ", pid_t " pgrp );
34 .SH DESCRIPTION
35 The function
36 .BR tcgetpgrp ()
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.
42 .LP
43 The function
44 .BR tcsetpgrp ()
45 makes the process group with process group ID
46 .I pgrp
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.
51 Moreover,
52 .I pgrp
53 must be a (nonempty) process group belonging to
54 the same session as the calling process.
55 .LP
56 If
57 .BR tcsetpgrp ()
58 is called by a member of a background process group in its session,
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.
64 .SH RETURN VALUE
65 When
66 .I fd
67 refers to the controlling terminal of the calling process,
68 the function
69 .BR tcgetpgrp ()
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.
79 .LP
80 When successful,
81 .BR tcsetpgrp ()
82 returns 0.
83 Otherwise, it returns \-1, and
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
101 .BR tcsetpgrp (),
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.
109 .SH ATTRIBUTES
110 .SS Multithreading (see pthreads(7))
111 The
112 .BR tcgetpgrp ()
113 and
114 .BR tcsetpgrp ()
115 functions are thread-safe.
116 .SH CONFORMING TO
117 POSIX.1-2001.
118 .SH NOTES
119 These functions are implemented via the
120 .B TIOCGPGRP
121 and
122 .B TIOCSPGRP
123 ioctls.
124 .SS History
125 The ioctls appeared in 4.2BSD.
126 The functions are POSIX inventions.
127 .SH SEE ALSO
128 .BR setpgid (2),
129 .BR setsid (2),
130 .BR credentials (7)
131 .SH COLOPHON
132 This page is part of release 3.79 of the Linux
133 .I man-pages
134 project.
135 A description of the project,
136 information about reporting bugs,
137 and the latest version of this page,
138 can be found at
139 \%http://www.kernel.org/doc/man\-pages/.