1*8269e767SBrooks Davis.\" Copyright (c) 1983, 1991, 1993 2*8269e767SBrooks Davis.\" The Regents of the University of California. All rights reserved. 3*8269e767SBrooks Davis.\" 4*8269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without 5*8269e767SBrooks Davis.\" modification, are permitted provided that the following conditions 6*8269e767SBrooks Davis.\" are met: 7*8269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright 8*8269e767SBrooks Davis.\" notice, this list of conditions and the following disclaimer. 9*8269e767SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright 10*8269e767SBrooks Davis.\" notice, this list of conditions and the following disclaimer in the 11*8269e767SBrooks Davis.\" documentation and/or other materials provided with the distribution. 12*8269e767SBrooks Davis.\" 3. Neither the name of the University nor the names of its contributors 13*8269e767SBrooks Davis.\" may be used to endorse or promote products derived from this software 14*8269e767SBrooks Davis.\" without specific prior written permission. 15*8269e767SBrooks Davis.\" 16*8269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17*8269e767SBrooks Davis.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18*8269e767SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19*8269e767SBrooks Davis.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20*8269e767SBrooks Davis.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21*8269e767SBrooks Davis.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22*8269e767SBrooks Davis.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23*8269e767SBrooks Davis.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24*8269e767SBrooks Davis.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25*8269e767SBrooks Davis.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26*8269e767SBrooks Davis.\" SUCH DAMAGE. 27*8269e767SBrooks Davis.\" 28*8269e767SBrooks Davis.Dd June 4, 1993 29*8269e767SBrooks Davis.Dt GETPGRP 2 30*8269e767SBrooks Davis.Os 31*8269e767SBrooks Davis.Sh NAME 32*8269e767SBrooks Davis.Nm getpgrp 33*8269e767SBrooks Davis.Nd get process group 34*8269e767SBrooks Davis.Sh LIBRARY 35*8269e767SBrooks Davis.Lb libc 36*8269e767SBrooks Davis.Sh SYNOPSIS 37*8269e767SBrooks Davis.In unistd.h 38*8269e767SBrooks Davis.Ft pid_t 39*8269e767SBrooks Davis.Fn getpgrp void 40*8269e767SBrooks Davis.Ft pid_t 41*8269e767SBrooks Davis.Fn getpgid "pid_t pid" 42*8269e767SBrooks Davis.Sh DESCRIPTION 43*8269e767SBrooks DavisThe process group of the current process is returned by 44*8269e767SBrooks Davis.Fn getpgrp . 45*8269e767SBrooks DavisThe process group of the process identified by 46*8269e767SBrooks Davis.Fa pid 47*8269e767SBrooks Davisis returned by 48*8269e767SBrooks Davis.Fn getpgid . 49*8269e767SBrooks DavisIf 50*8269e767SBrooks Davis.Fa pid 51*8269e767SBrooks Davisis zero, 52*8269e767SBrooks Davis.Fn getpgid 53*8269e767SBrooks Davisreturns the process group of the current process. 54*8269e767SBrooks Davis.Pp 55*8269e767SBrooks DavisProcess groups are used for distribution of signals, and 56*8269e767SBrooks Davisby terminals to arbitrate requests for their input: processes 57*8269e767SBrooks Davisthat have the same process group as the terminal are foreground 58*8269e767SBrooks Davisand may read, while others will block with a signal if they attempt 59*8269e767SBrooks Davisto read. 60*8269e767SBrooks Davis.Pp 61*8269e767SBrooks DavisThis system call is thus used by programs such as 62*8269e767SBrooks Davis.Xr csh 1 63*8269e767SBrooks Davisto create 64*8269e767SBrooks Davisprocess groups 65*8269e767SBrooks Davisin implementing job control. 66*8269e767SBrooks DavisThe 67*8269e767SBrooks Davis.Fn tcgetpgrp 68*8269e767SBrooks Davisand 69*8269e767SBrooks Davis.Fn tcsetpgrp 70*8269e767SBrooks Daviscalls 71*8269e767SBrooks Davisare used to get/set the process group of the control terminal. 72*8269e767SBrooks Davis.Sh RETURN VALUES 73*8269e767SBrooks DavisThe 74*8269e767SBrooks Davis.Fn getpgrp 75*8269e767SBrooks Davissystem call always succeeds. 76*8269e767SBrooks DavisUpon successful completion, the 77*8269e767SBrooks Davis.Fn getpgid 78*8269e767SBrooks Davissystem call returns the process group of the specified process; 79*8269e767SBrooks Davisotherwise, it returns a value of \-1 and sets 80*8269e767SBrooks Davis.Va errno 81*8269e767SBrooks Davisto indicate the error. 82*8269e767SBrooks Davis.Sh COMPATIBILITY 83*8269e767SBrooks DavisThis version of 84*8269e767SBrooks Davis.Fn getpgrp 85*8269e767SBrooks Davisdiffers from past Berkeley versions by not taking a 86*8269e767SBrooks Davis.Fa "pid_t pid" 87*8269e767SBrooks Davisargument. 88*8269e767SBrooks DavisThis incompatibility is required by 89*8269e767SBrooks Davis.St -p1003.1-90 . 90*8269e767SBrooks Davis.Pp 91*8269e767SBrooks DavisFrom the 92*8269e767SBrooks Davis.St -p1003.1-90 93*8269e767SBrooks DavisRationale: 94*8269e767SBrooks Davis.Pp 95*8269e767SBrooks Davis.Bx 4.3 96*8269e767SBrooks Davisprovides a 97*8269e767SBrooks Davis.Fn getpgrp 98*8269e767SBrooks Davissystem call that returns the process group ID for a specified process. 99*8269e767SBrooks DavisAlthough this function is used to support job control, all known 100*8269e767SBrooks Davisjob-control shells always specify the calling process with this 101*8269e767SBrooks Davisfunction. 102*8269e767SBrooks DavisThus, the simpler 103*8269e767SBrooks Davis.At V 104*8269e767SBrooks Davis.Fn getpgrp 105*8269e767SBrooks Davissuffices, and the added complexity of the 106*8269e767SBrooks Davis.Bx 4.3 107*8269e767SBrooks Davis.Fn getpgrp 108*8269e767SBrooks Davishas been omitted from POSIX.1. 109*8269e767SBrooks DavisThe old functionality is available from the 110*8269e767SBrooks Davis.Fn getpgid 111*8269e767SBrooks Davissystem call. 112*8269e767SBrooks Davis.Sh ERRORS 113*8269e767SBrooks DavisThe 114*8269e767SBrooks Davis.Fn getpgid 115*8269e767SBrooks Davissystem call 116*8269e767SBrooks Daviswill succeed unless: 117*8269e767SBrooks Davis.Bl -tag -width Er 118*8269e767SBrooks Davis.It Bq Er ESRCH 119*8269e767SBrooks Davisthere is no process whose process ID equals 120*8269e767SBrooks Davis.Fa pid 121*8269e767SBrooks Davis.El 122*8269e767SBrooks Davis.Sh SEE ALSO 123*8269e767SBrooks Davis.Xr getsid 2 , 124*8269e767SBrooks Davis.Xr setpgid 2 , 125*8269e767SBrooks Davis.Xr termios 4 126*8269e767SBrooks Davis.Sh STANDARDS 127*8269e767SBrooks DavisThe 128*8269e767SBrooks Davis.Fn getpgrp 129*8269e767SBrooks Davissystem call is expected to conform to 130*8269e767SBrooks Davis.St -p1003.1-90 . 131*8269e767SBrooks Davis.Sh HISTORY 132*8269e767SBrooks DavisThe 133*8269e767SBrooks Davis.Fn getpgrp 134*8269e767SBrooks Davissystem call appeared in 135*8269e767SBrooks Davis.Bx 4.0 . 136*8269e767SBrooks DavisThe 137*8269e767SBrooks Davis.Fn getpgid 138*8269e767SBrooks Davissystem call is derived from its usage in 139*8269e767SBrooks Davis.At V.4 . 140