xref: /openbsd/lib/libc/termios/tcsetpgrp.3 (revision 73be947e)
1.\"	$OpenBSD: tcsetpgrp.3,v 1.15 2023/01/12 12:56:07 jsg Exp $
2.\"
3.\" Copyright (c) 1991 The Regents of the University of California.
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.Dd $Mdocdate: January 12 2023 $
31.Dt TCSETPGRP 3
32.Os
33.Sh NAME
34.Nm tcsetpgrp
35.Nd set foreground process group ID
36.Sh SYNOPSIS
37.In unistd.h
38.Ft int
39.Fn tcsetpgrp "int fd" "pid_t pgrp_id"
40.Sh DESCRIPTION
41If the process has a controlling terminal, the
42.Fn tcsetpgrp
43function sets the foreground process group ID associated with the
44terminal device to
45.Fa pgrp_id .
46The terminal device associated with
47.Fa fd
48must be the controlling terminal of the calling process and the
49controlling terminal must be currently associated with the session
50of the calling process.
51The value of
52.Fa pgrp_id
53must be the same as the process group ID of a process in the same
54session as the calling process.
55.Pp
56If the calling process is a member of a background process group,
57the process group will be sent a
58.Dv SIGTTOU
59signal.
60If the calling process is blocking or ignoring
61.Dv SIGTTOU
62signals, the process is allowed to perform the operation and the
63.Dv SIGTTOU
64signal is not sent.
65.Pp
66Upon successful completion,
67.Fn tcsetpgrp
68returns a value of zero.
69.Sh ERRORS
70If an error occurs,
71.Fn tcsetpgrp
72returns \-1 and the global variable
73.Va errno
74is set to indicate the error, as follows:
75.Bl -tag -width Er
76.It Bq Er EBADF
77The
78.Fa fd
79argument is not a valid file descriptor.
80.It Bq Er EINTR
81The
82.Fn tcsetpgrp
83function was interrupted by a signal.
84.It Bq Er EINVAL
85An invalid value of
86.Fa pgrp_id
87was specified.
88.It Bq Er ENOTTY
89The calling process does not have a controlling terminal, or the file
90represented by
91.Fa fd
92is not the controlling terminal, or the controlling terminal is no
93longer associated with the session of the calling process.
94.It Bq Er EPERM
95The
96.Fa pgrp_id
97argument does not match the process group ID of a process in the same
98session as the calling process.
99.El
100.Sh SEE ALSO
101.Xr setpgid 2 ,
102.Xr setsid 2 ,
103.Xr tcgetpgrp 3
104.Sh STANDARDS
105The
106.Fn tcsetpgrp
107function is compliant with the
108.St -p1003.1-88
109specification.
110