]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man/man3/tcgetpgrp.3
man/, share/mk/: Move man*/ to man/
[thirdparty/man-pages.git] / man / man3 / tcgetpgrp.3
CommitLineData
a1eaacb1 1'\" t
fea681da
MK
2.\" Copyright (C) 2002 Andries Brouwer <aeb@cwi.nl>
3.\"
5fbde956 4.\" SPDX-License-Identifier: Linux-man-pages-copyleft
fea681da 5.\"
4c1c5274 6.TH tcgetpgrp 3 (date) "Linux man-pages (unreleased)"
fea681da
MK
7.SH NAME
8tcgetpgrp, tcsetpgrp \- get and set terminal foreground process group
95572a8b
AC
9.SH LIBRARY
10Standard C library
8fc3b2cf 11.RI ( libc ", " \-lc )
fea681da 12.SH SYNOPSIS
15d65653 13.nf
0daa9e92 14.B "#include <unistd.h>"
c6d039a3 15.P
fea681da 16.BI "pid_t tcgetpgrp(int " fd );
fea681da 17.BI "int tcsetpgrp(int " fd ", pid_t " pgrp );
15d65653 18.fi
fea681da
MK
19.SH DESCRIPTION
20The function
63aa9df0 21.BR tcgetpgrp ()
fea681da
MK
22returns the process group ID of the foreground process group on the
23terminal associated to
24.IR fd ,
25which must be the controlling terminal of the calling process.
26.\" The process itself may be a background process.
c6d039a3 27.P
fea681da 28The function
63aa9df0 29.BR tcsetpgrp ()
c6fa0841
MK
30makes the process group with process group ID
31.I pgrp
fea681da
MK
32the foreground process group on the terminal associated to
33.IR fd ,
34which must be the controlling terminal of the calling process,
35and still be associated with its session.
c6fa0841
MK
36Moreover,
37.I pgrp
38must be a (nonempty) process group belonging to
fea681da 39the same session as the calling process.
c6d039a3 40.P
fea681da 41If
63aa9df0 42.BR tcsetpgrp ()
fea681da 43is called by a member of a background process group in its session,
8bd58774
MK
44and the calling process is not blocking or ignoring
45.BR SIGTTOU ,
46a
47.B SIGTTOU
48signal is sent to all members of this background process group.
47297adb 49.SH RETURN VALUE
fea681da
MK
50When
51.I fd
52refers to the controlling terminal of the calling process,
53the function
63aa9df0 54.BR tcgetpgrp ()
fea681da
MK
55will return the foreground process group ID of that terminal
56if there is one, and some value larger than 1 that is not
57presently a process group ID otherwise.
58When
59.I fd
60does not refer to the controlling terminal of the calling process,
61\-1 is returned, and
62.I errno
f6a4078b 63is set to indicate the error.
c6d039a3 64.P
fea681da 65When successful,
63aa9df0 66.BR tcsetpgrp ()
677f4766
MK
67returns 0.
68Otherwise, it returns \-1, and
fea681da 69.I errno
f6a4078b 70is set to indicate the error.
fea681da
MK
71.SH ERRORS
72.TP
73.B EBADF
74.I fd
75is not a valid file descriptor.
76.TP
77.B EINVAL
78.I pgrp
79has an unsupported value.
80.TP
81.B ENOTTY
82The calling process does not have a controlling terminal, or
83it has one but it is not described by
84.IR fd ,
85or, for
63aa9df0 86.BR tcsetpgrp (),
fea681da
MK
87this controlling terminal is no longer associated with the session
88of the calling process.
89.TP
90.B EPERM
91.I pgrp
92has a supported value, but is not the process group ID of a
93process in the same session as the calling process.
8f9d0619 94.SH ATTRIBUTES
5bcd1ce4
PH
95For an explanation of the terms used in this section, see
96.BR attributes (7).
97.TS
98allbox;
c466875e 99lbx lb lb
5bcd1ce4
PH
100l l l.
101Interface Attribute Value
102T{
9e54434e
BR
103.na
104.nh
5bcd1ce4 105.BR tcgetpgrp (),
8f9d0619 106.BR tcsetpgrp ()
5bcd1ce4
PH
107T} Thread safety MT-Safe
108.TE
4131356c 109.SH VERSIONS
097585ed
MK
110These functions are implemented via the
111.B TIOCGPGRP
112and
113.B TIOCSPGRP
114ioctls.
4131356c
AC
115.SH STANDARDS
116POSIX.1-2008.
117.SH HISTORY
118POSIX.1-2001.
c6d039a3 119.P
889829be 120The ioctls appeared in 4.2BSD.
1c44bd5b 121The functions are POSIX inventions.
47297adb 122.SH SEE ALSO
fea681da 123.BR setpgid (2),
53a1443c
MK
124.BR setsid (2),
125.BR credentials (7)