xref: /original-bsd/lib/libc/sys/setpgid.2 (revision c3e32dec)
1.\" Copyright (c) 1980, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)setpgid.2	8.1 (Berkeley) 06/04/93
7.\"
8.Dd
9.Dt SETPGID 2
10.Os BSD 4
11.Sh NAME
12.Nm setpgid ,
13.Nm setpgrp
14.Nd set process group
15.Sh SYNOPSIS
16.Fd #include <unistd.h>
17.Ft int
18.Fn setpgid pid_tpid pid_tpgrp
19.Ft int
20.Fn setpgrp pid_tpid pid_tpgrp
21.Sh DESCRIPTION
22.Fn Setpgid
23sets the process group of the specified process
24.Ar pid
25to the specified
26.Ar pgrp .
27If
28.Ar pid
29is zero, then the call applies to the current process.
30.Pp
31If the invoker is not the super-user, then the affected process
32must have the same effective user-id as the invoker or be a descendant
33of the invoking process.
34.Sh RETURN VALUES
35.Fn Setpgid
36returns 0 when the operation was successful.
37If the request failed, -1 is returned and the global variable
38.Va errno
39indicates the reason.
40.Sh ERRORS
41.Fn Setpgid
42will fail and the process group will not be altered if:
43.Bl -tag -width indent
44.It Bq Er ESRCH
45The requested process does not exist.
46.It Bq Er EPERM
47The effective user ID of the requested process is different
48from that of the caller and the process is not a descendent
49of the calling process.
50.El
51.Sh SEE ALSO
52.Xr getpgrp 2
53.Sh STANDARDS
54.Fn Setpgid
55conforms to IEEE Std 1003.1-1988
56.Pq Dq Tn POSIX .
57.Sh COMPATIBILITY
58.Fn Setpgrp
59is identical to
60.Fn setpgid ,
61and is retained for calling convention compatibility with historical
62versions of
63.Bx .
64