]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/tcgetpgrp.3
getent.1, intro.1, time.1, _exit.2, _syscall.2, accept.2, access.2, acct.2, adjtimex...
[thirdparty/man-pages.git] / man3 / tcgetpgrp.3
CommitLineData
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
25tcgetpgrp, tcsetpgrp \- get and set terminal foreground process group
26.SH SYNOPSIS
0daa9e92 27.B "#include <unistd.h>"
fea681da
MK
28.sp
29.BI "pid_t tcgetpgrp(int " fd );
30.sp
31.BI "int tcsetpgrp(int " fd ", pid_t " pgrp );
32.SH DESCRIPTION
33The function
63aa9df0 34.BR tcgetpgrp ()
fea681da
MK
35returns the process group ID of the foreground process group on the
36terminal associated to
37.IR fd ,
38which must be the controlling terminal of the calling process.
39.\" The process itself may be a background process.
40.LP
41The function
63aa9df0 42.BR tcsetpgrp ()
fea681da
MK
43makes the process group with process group ID \fIpgrp\fP
44the foreground process group on the terminal associated to
45.IR fd ,
46which must be the controlling terminal of the calling process,
47and still be associated with its session.
aa796481 48Moreover, \fIpgrp\fP must be a (nonempty) process group belonging to
fea681da
MK
49the same session as the calling process.
50.LP
51If
63aa9df0 52.BR tcsetpgrp ()
fea681da 53is called by a member of a background process group in its session,
8bd58774
MK
54and the calling process is not blocking or ignoring
55.BR SIGTTOU ,
56a
57.B SIGTTOU
58signal is sent to all members of this background process group.
47297adb 59.SH RETURN VALUE
fea681da
MK
60When
61.I fd
62refers to the controlling terminal of the calling process,
63the function
63aa9df0 64.BR tcgetpgrp ()
fea681da
MK
65will return the foreground process group ID of that terminal
66if there is one, and some value larger than 1 that is not
67presently a process group ID otherwise.
68When
69.I fd
70does not refer to the controlling terminal of the calling process,
71\-1 is returned, and
72.I errno
73is set appropriately.
74.LP
75When successful,
63aa9df0 76.BR tcsetpgrp ()
677f4766
MK
77returns 0.
78Otherwise, it returns \-1, and
fea681da
MK
79.I errno
80is set appropriately.
81.SH ERRORS
82.TP
83.B EBADF
84.I fd
85is not a valid file descriptor.
86.TP
87.B EINVAL
88.I pgrp
89has an unsupported value.
90.TP
91.B ENOTTY
92The calling process does not have a controlling terminal, or
93it has one but it is not described by
94.IR fd ,
95or, for
63aa9df0 96.BR tcsetpgrp (),
fea681da
MK
97this controlling terminal is no longer associated with the session
98of the calling process.
99.TP
100.B EPERM
101.I pgrp
102has a supported value, but is not the process group ID of a
103process in the same session as the calling process.
47297adb 104.SH CONFORMING TO
2b2581ee 105POSIX.1-2001.
fea681da 106.SH NOTES
097585ed
MK
107These functions are implemented via the
108.B TIOCGPGRP
109and
110.B TIOCSPGRP
111ioctls.
889829be
MK
112.SS History
113The ioctls appeared in 4.2BSD.
1c44bd5b 114The functions are POSIX inventions.
47297adb 115.SH SEE ALSO
fea681da 116.BR setpgid (2),
53a1443c
MK
117.BR setsid (2),
118.BR credentials (7)