OSDN Git Service

(split) LDP: Change Makefile to stamp-based compilation
[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 2003-01-28 "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 \fIpgrp\fP
46 the foreground process group on the terminal associated to
47 .IR fd ,
48 which must be the controlling terminal of the calling process,
49 and still be associated with its session.
50 Moreover, \fIpgrp\fP must be a (nonempty) process group belonging to
51 the same session as the calling process.
52 .LP
53 If
54 .BR tcsetpgrp ()
55 is called by a member of a background process group in its session,
56 and the calling process is not blocking or ignoring
57 .BR SIGTTOU ,
58 a
59 .B SIGTTOU
60 signal is sent to all members of this background process group.
61 .SH RETURN VALUE
62 When
63 .I fd
64 refers to the controlling terminal of the calling process,
65 the function
66 .BR tcgetpgrp ()
67 will return the foreground process group ID of that terminal
68 if there is one, and some value larger than 1 that is not
69 presently a process group ID otherwise.
70 When
71 .I fd
72 does not refer to the controlling terminal of the calling process,
73 \-1 is returned, and
74 .I errno
75 is set appropriately.
76 .LP
77 When successful,
78 .BR tcsetpgrp ()
79 returns 0.
80 Otherwise, it returns \-1, and
81 .I errno
82 is set appropriately.
83 .SH ERRORS
84 .TP
85 .B EBADF
86 .I fd
87 is not a valid file descriptor.
88 .TP
89 .B EINVAL
90 .I pgrp
91 has an unsupported value.
92 .TP
93 .B ENOTTY
94 The calling process does not have a controlling terminal, or
95 it has one but it is not described by
96 .IR fd ,
97 or, for
98 .BR tcsetpgrp (),
99 this controlling terminal is no longer associated with the session
100 of the calling process.
101 .TP
102 .B EPERM
103 .I pgrp
104 has a supported value, but is not the process group ID of a
105 process in the same session as the calling process.
106 .SH CONFORMING TO
107 POSIX.1-2001.
108 .SH NOTES
109 These functions are implemented via the
110 .B TIOCGPGRP
111 and
112 .B TIOCSPGRP
113 ioctls.
114 .SS History
115 The ioctls appeared in 4.2BSD.
116 The functions are POSIX inventions.
117 .SH SEE ALSO
118 .BR setpgid (2),
119 .BR setsid (2),
120 .BR credentials (7)