]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/tcgetpgrp.3
mlock.2: tfix
[thirdparty/man-pages.git] / man3 / tcgetpgrp.3
CommitLineData
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
27tcgetpgrp, 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
35The function
63aa9df0 36.BR tcgetpgrp ()
fea681da
MK
37returns the process group ID of the foreground process group on the
38terminal associated to
39.IR fd ,
40which must be the controlling terminal of the calling process.
41.\" The process itself may be a background process.
dd3568a1 42.PP
fea681da 43The function
63aa9df0 44.BR tcsetpgrp ()
c6fa0841
MK
45makes the process group with process group ID
46.I pgrp
fea681da
MK
47the foreground process group on the terminal associated to
48.IR fd ,
49which must be the controlling terminal of the calling process,
50and still be associated with its session.
c6fa0841
MK
51Moreover,
52.I pgrp
53must be a (nonempty) process group belonging to
fea681da 54the same session as the calling process.
dd3568a1 55.PP
fea681da 56If
63aa9df0 57.BR tcsetpgrp ()
fea681da 58is called by a member of a background process group in its session,
8bd58774
MK
59and the calling process is not blocking or ignoring
60.BR SIGTTOU ,
61a
62.B SIGTTOU
63signal is sent to all members of this background process group.
47297adb 64.SH RETURN VALUE
fea681da
MK
65When
66.I fd
67refers to the controlling terminal of the calling process,
68the function
63aa9df0 69.BR tcgetpgrp ()
fea681da
MK
70will return the foreground process group ID of that terminal
71if there is one, and some value larger than 1 that is not
72presently a process group ID otherwise.
73When
74.I fd
75does not refer to the controlling terminal of the calling process,
76\-1 is returned, and
77.I errno
78is set appropriately.
dd3568a1 79.PP
fea681da 80When successful,
63aa9df0 81.BR tcsetpgrp ()
677f4766
MK
82returns 0.
83Otherwise, it returns \-1, and
fea681da
MK
84.I errno
85is set appropriately.
86.SH ERRORS
87.TP
88.B EBADF
89.I fd
90is not a valid file descriptor.
91.TP
92.B EINVAL
93.I pgrp
94has an unsupported value.
95.TP
96.B ENOTTY
97The calling process does not have a controlling terminal, or
98it has one but it is not described by
99.IR fd ,
100or, for
63aa9df0 101.BR tcsetpgrp (),
fea681da
MK
102this controlling terminal is no longer associated with the session
103of the calling process.
104.TP
105.B EPERM
106.I pgrp
107has a supported value, but is not the process group ID of a
108process in the same session as the calling process.
8f9d0619 109.SH ATTRIBUTES
5bcd1ce4
PH
110For an explanation of the terms used in this section, see
111.BR attributes (7).
112.TS
113allbox;
114lbw24 lb lb
115l l l.
116Interface Attribute Value
117T{
118.BR tcgetpgrp (),
8f9d0619 119.BR tcsetpgrp ()
5bcd1ce4
PH
120T} Thread safety MT-Safe
121.TE
47297adb 122.SH CONFORMING TO
a143c891 123POSIX.1-2001, POSIX.1-2008.
fea681da 124.SH NOTES
097585ed
MK
125These functions are implemented via the
126.B TIOCGPGRP
127and
128.B TIOCSPGRP
129ioctls.
889829be
MK
130.SS History
131The ioctls appeared in 4.2BSD.
1c44bd5b 132The functions are POSIX inventions.
47297adb 133.SH SEE ALSO
fea681da 134.BR setpgid (2),
53a1443c
MK
135.BR setsid (2),
136.BR credentials (7)