Sets the process group ID for job control. This function is supported on OpenVMS Integrity servers and Alpha only. Format #include <unistd.h> int setpgid (pid_t pid, pid_t pgid);
1 – Arguments
pid The process ID for which the process group ID is to be set. pgid The value to which the process group ID is set.
2 – Description
The setpgid function is used either to join an existing process group or create a new process group within the session of the calling process. The process group ID of a session leader will not change. Upon successful completion, the process group ID of the process with a process ID of pid is set to pgid. As a special case, if pid is 0, the process ID of the calling process is used. Also, if pgid is 0, the process group ID of the indicated process is used. This function requires that long (32-bit) UID/GID support be enabled. See 32-Bit UID and GID Macro (Integrity servers, Alpha) for more information.
3 – Return Values
0 Successful completion. -1 Indicates an error. The function sets errno to one of the following values: o EACCES - The value of the pid argument matches the process ID of a child process of the calling process and the child process has successfully executed one of the exec functions. o EINVAL - The value of the pgid argument is less than 0, or is not a value supported by the implementation. o EPERM - The process indicated by the pid argument is a session leader. The value of the pid argument matches the process ID of a child process of the calling process, and the child process is not in the same session as the calling process. The value of the pgid argument is valid but does not match the process ID of the process indicated by the pid argument, and there is no process with a process group ID that matches the value of the pgid argument in the same session as the calling process. o ESRCH - The value of the pid argument does not match the process ID of the calling process or of a child process of the calling process.