'\" te .\" Copyright 1989 AT&T Copyright (c) 1997, Sun Microsystems, Inc. All Rights Reserved .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] .TH setpgid 2 "28 Dec 1996" "SunOS 5.11" "System Calls" .SH NAME setpgid \- set process group ID .SH SYNOPSIS .LP .nf #include #include \fBint\fR \fBsetpgid\fR(\fBpid_t\fR \fIpid\fR, \fBpid_t\fR \fIpgid\fR); .fi .SH DESCRIPTION .sp .LP The \fBsetpgid()\fR function sets the process group \fBID\fR of the process with \fBID\fR \fIpid\fR to \fIpgid\fR. .sp .LP If \fIpgid\fR is equal to \fIpid\fR, the process becomes a process group leader. See \fBIntro\fR(2) for more information on session leaders and process group leaders. .sp .LP If \fIpgid\fR is not equal to \fIpid\fR, the process becomes a member of an existing process group. .sp .LP If \fIpid\fR is equal to 0, the process \fBID\fR of the calling process is used. If \fIpgid\fR is equal to 0, the process specified by \fIpid\fR becomes a process group leader. .SH RETURN VALUES .sp .LP Upon successful completion, \fB0\fR is returned. Otherwise, \fB\(mi1\fR is returned and \fBerrno\fR is set to indicate the error. .SH ERRORS .sp .LP The \fBsetpgid()\fR function will fail if: .sp .ne 2 .mk .na \fB\fBEACCES\fR\fR .ad .RS 10n .rt The \fIpid\fR argument matches the process \fBID\fR of a child process of the calling process and the child process has successfully executed one of the \fIexec\fR family of functions (see \fBexec\fR(2)). .RE .sp .ne 2 .mk .na \fB\fBEINVAL\fR\fR .ad .RS 10n .rt The \fIpgid\fR argument is less than (\fBpid_t) 0\fR or greater than or equal to \fBPID_MAX\fR, or the calling process has a controlling terminal that does not support job control. .RE .sp .ne 2 .mk .na \fB\fBEPERM\fR\fR .ad .RS 10n .rt The process indicated by the \fIpid\fR argument is a session leader. .RE .sp .ne 2 .mk .na \fB\fBEPERM\fR\fR .ad .RS 10n .rt The \fIpid\fR argument matches the process \fBID\fR of a child process of the calling process and the child process is not in the same session as the calling process. .RE .sp .ne 2 .mk .na \fB\fBEPERM\fR\fR .ad .RS 10n .rt The \fIpgid\fR argument does not match the process \fBID\fR of the process indicated by the \fIpid\fR argument, and there is no process with a process group \fBID\fR that matches \fIpgid\fR in the same session as the calling process. .RE .sp .ne 2 .mk .na \fB\fBESRCH\fR\fR .ad .RS 10n .rt The \fIpid\fR argument does not match the process \fBID\fR of the calling process or of a child process of the calling process. .RE .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ Interface StabilityStandard _ MT-LevelAsync-Signal-Safe .TE .SH SEE ALSO .sp .LP \fBIntro\fR(2), \fBexec\fR(2), \fBexit\fR(2), \fBfork\fR(2), \fBgetpid\fR(2), \fBgetsid\fR(2), \fBattributes\fR(5), \fBstandards\fR(5)