4.4BSD snapshot (revision 8.1); add 1993 to copyright
[unix-history] / usr / src / lib / libc / sys / setpgid.2
.\" Copyright (c) 1980, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" %sccs.include.redist.man%
.\"
.\" @(#)setpgid.2 8.1 (Berkeley) %G%
.\"
.Dd
.Dt SETPGID 2
.Os BSD 4
.Sh NAME
.Nm setpgid ,
.Nm setpgrp
.Nd set process group
.Sh SYNOPSIS
.Fd #include <unistd.h>
.Ft int
.Fn setpgid pid_tpid pid_tpgrp
.Ft int
.Fn setpgrp pid_tpid pid_tpgrp
.Sh DESCRIPTION
.Fn Setpgid
sets the process group of the specified process
.Ar pid
to the specified
.Ar pgrp .
If
.Ar pid
is zero, then the call applies to the current process.
.Pp
If the invoker is not the super-user, then the affected process
must have the same effective user-id as the invoker or be a descendant
of the invoking process.
.Sh RETURN VALUES
.Fn Setpgid
returns 0 when the operation was successful.
If the request failed, -1 is returned and the global variable
.Va errno
indicates the reason.
.Sh ERRORS
.Fn Setpgid
will fail and the process group will not be altered if:
.Bl -tag -width indent
.It Bq Er ESRCH
The requested process does not exist.
.It Bq Er EPERM
The effective user ID of the requested process is different
from that of the caller and the process is not a descendent
of the calling process.
.El
.Sh SEE ALSO
.Xr getpgrp 2
.Sh STANDARDS
.Fn Setpgid
conforms to IEEE Std 1003.1-1988
.Pq Dq Tn POSIX .
.Sh COMPATIBILITY
.Fn Setpgrp
is identical to
.Fn setpgid ,
and is retained for calling convention compatibility with historical
versions of
.Bx .