Sets the process group ID.
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.
In BSD systems, the setpgrp subroutine is defined with two parameters, as follows:
int setpgrp (ProcessID, ProcessGroup) int ProcessID, ProcessGroup;
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:
The getpid subroutine.