'\"macro stdmacro
.if n .pH g3c.tcsetpgrp @(#)tcsetpgrp	40.11 of 10/27/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} tcsetpgrp 3C "" "\&"
.if \nX=1 .ds x} tcsetpgrp 3C ""
.if \nX=2 .ds x} tcsetpgrp 3C "" "\&"
.if \nX=3 .ds x} tcsetpgrp "" "" "\&"
.TH \*(x}
.SH NAME
\f4tcsetpgrp\f1 \- set terminal foreground process group id
.SH SYNOPSIS
\f4#include <unistd.h>\fP
.PP
\f4int tcsetpgrp (int fildes, pid_t pgid)\f1
.SH DESCRIPTION
\f4tcsetpgrp\fP
sets the foreground process group
.SM ID
of the terminal specified by
.I fildes
to
.IR pgid .
The file associated with \f2fildes\fP must be the controlling terminal
of the calling process and the controlling terminal must be currently
associated with the session of the calling process.
The value of \f2pgid\fP must match a process group
.SM ID
of a process in the same session as the calling process.
.PP
\f4tcsetpgrp\fP fails if one or more of the following is true:
.TP 15
\f4EBADF\fP
The
.I fildes\^
argument is not a valid file descriptor.
.TP 15
\f4EINVAL\fP
The
.I fildes\^
argument is a terminal that does not support 
\f4tcsetpgrp\fP, or
.I pgid
is not a valid process group \s-1ID\s+1.
.TP 15
\f4ENOTTY\fP
The calling process does not have a controlling terminal, or the file is
not the controlling terminal, or the controlling terminal is no longer
associated with the session of the calling process.
.TP 15
\f4EPERM\fP
.I pgid
does not match the process group 
.SM ID
of an existing process in the same session as the calling process.
.SH SEE ALSO
\f4tcsetpgrp\fP(3C), \f4tcsetsid\fP(3C).
.br
\f4termio\fP(7) in the \f2System Administrator's Reference Manual\f1.
.SH DIAGNOSTICS
Upon successful completion,
\f4tcsetpgrp\fP
returns a value of 0.
Otherwise, a value of \-1 is returned and
\f4errno\fP
is set to indicate the error.
