1.\" $NetBSD: getpgrp.2,v 1.23 2009/03/23 14:11:27 joerg 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 ERRORS 73.Fn getpgrp 74always succeeds, however 75.Fn getpgid 76will succeed unless: 77.Bl -tag -width Er 78.It Bq Er ESRCH 79if there is no process with a process ID equal to 80.Fa pid . 81.El 82.Sh SEE ALSO 83.Xr setpgid 2 , 84.Xr termios 4 85.Sh STANDARDS 86The 87.Fn getpgrp 88function conforms to 89.St -p1003.1-88 . 90.Sh HISTORY 91The 92.Fn getpgrp 93function call appeared in 94.Bx 4.0 . 95The 96.Fn getpgid 97function call is derived from its usage in 98.At V.4 , 99and first appeared in 100.Nx 1.3 . 101.Sh COMPATIBILITY 102This version of 103.Fn getpgrp 104differs from past Berkeley versions by not taking a 105.Fa "pid_t pid" 106argument. 107This incompatibility is required by 108.St -p1003.1-90 . 109.Pp 110From the 111.St -p1003.1-90 112Rationale: 113.Lp 114.Bx 4.3 115provides a 116.Fn getpgrp 117function that returns the process group ID for a specified process. 118Although this function is used to support job control, all known 119job-control shells always specify the calling process with this 120function. 121Thus, the simpler System V 122.Fn getpgrp 123suffices, and the added complexity of the 124.Bx 4.3 125.Fn getpgrp 126has been omitted from POSIX.1. 127The old functionality is available from the 128.Fn getpgid 129function. 130