xref: /minix/lib/libc/sys/getpgrp.2 (revision 0a6a1f1d)
1.\"	$NetBSD: getpgrp.2,v 1.24 2014/09/19 16:02:58 wiz Exp $
2.\"
3.\" Copyright (c) 1983, 1991, 1993
4.\"	The Regents of the University of California.  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.\"     @(#)getpgrp.2	8.1 (Berkeley) 6/4/93
31.\"
32.Dd August 11, 2002
33.Dt GETPGRP 2
34.Os
35.Sh NAME
36.Nm getpgrp ,
37.Nm getpgid
38.Nd get process group
39.Sh LIBRARY
40.Lb libc
41.Sh SYNOPSIS
42.In unistd.h
43.Ft pid_t
44.Fn getpgrp "void"
45.Ft pid_t
46.Fn getpgid "pid_t pid"
47.Sh DESCRIPTION
48The process group of the current process is returned by
49.Fn getpgrp .
50The process group of the
51.Fa pid
52process is returned by
53.Fn getpgid .
54.Pp
55Process groups are used for distribution of signals, and
56by terminals to arbitrate requests for their input: processes
57that have the same process group as the terminal are foreground
58and may read, while others will block with a signal if they attempt
59to read.
60.Pp
61This call is thus used by programs such as
62.Xr csh 1
63to create
64process groups
65in implementing job control.
66The
67.Fn tcgetpgrp
68and
69.Fn tcsetpgrp
70calls
71are used to get/set the process group of the control terminal.
72.Sh COMPATIBILITY
73This version of
74.Fn getpgrp
75differs from past Berkeley versions by not taking a
76.Fa "pid_t pid"
77argument.
78This incompatibility is required by
79.St -p1003.1-90 .
80.Pp
81From the
82.St -p1003.1-90
83Rationale:
84.Lp
85.Bx 4.3
86provides a
87.Fn getpgrp
88function that returns the process group ID for a specified process.
89Although this function is used to support job control, all known
90job-control shells always specify the calling process with this
91function.
92Thus, the simpler System V
93.Fn getpgrp
94suffices, and the added complexity of the
95.Bx 4.3
96.Fn getpgrp
97has been omitted from POSIX.1.
98The old functionality is available from the
99.Fn getpgid
100function.
101.Sh ERRORS
102.Fn getpgrp
103always succeeds, however
104.Fn getpgid
105will succeed unless:
106.Bl -tag -width Er
107.It Bq Er ESRCH
108if there is no process with a process ID equal to
109.Fa pid .
110.El
111.Sh SEE ALSO
112.Xr setpgid 2 ,
113.Xr termios 4
114.Sh STANDARDS
115The
116.Fn getpgrp
117function conforms to
118.St -p1003.1-88 .
119.Sh HISTORY
120The
121.Fn getpgrp
122function call appeared in
123.Bx 4.0 .
124The
125.Fn getpgid
126function call is derived from its usage in
127.At V.4 ,
128and first appeared in
129.Nx 1.3 .
130