setpgid: Standard C Library (libc.a)
setpgrp: Standard C Library (libc.a);
Berkeley Compatibility Library (libbsd.a)
#include <unistd.h>
int setpgid (ProcessID, ProcessGroupID) pid_t ProcessID, ProcessGroupID;
int setpgrp ( )
The setpgid subroutine is used either to join an existing process group or to create a new process group within the session of the calling process. The process group ID of a session leader does not change. Upon return, the process group ID of the process having a process ID that matches the ProcessID value is set to the ProcessGroupID value. As a special case, if the ProcessID value is 0, the process ID of the calling process is used. If ProcessGroupID value is 0, the process ID of the indicated process is used.
This function is implemented to support job control.
The setpgrp subroutine in the libc.a library supports a subset of the function of the setpgid subroutine. It has no parameters. It sets the process group ID of the calling process to be the same as its process ID and returns the new value.
ProcessID | Specifies the process whose process group ID is to be changed. |
ProcessGroupID | Specifies the new value of calling process group ID. |
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and the errno global variable is set to indicate the error.
The setpgid subroutine is unsuccessful if one or more of the following is true:
This subroutine is part of Base Operating System (BOS) Runtime.
In BSD systems, the setpgrp subroutine is defined with two parameters, as follows:
int setpgrp (ProcessID, ProcessGroup) int ProcessID, ProcessGroup;
BSD systems set the process group to the value specified by the ProcessGroup parameter. If the ProcessID value is 0, the call applies to the current process. In the Version 3 Operating System, this version of the setpgrp subroutine must be compiled with the Berkeley Compatibility Library (libbsd.a) and is implemented as a call to the setpgid subroutine. The restrictions that apply to the setpgid subroutine also apply to the setpgrp subroutine.
The getpid subroutine.