setpgid(2P) setpgid(2P)NAME setpgid - set process group ID for job control SYNOPSIS int setpgid(pid, pgid) pid_t pid, pgid; DESCRIPTION setpgid is used 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 group leader cannot be changed. The process group ID of the process specified by pid is set to pgid. If pid or pgid is 0, the process ID of the calling process is used. RETURN VALUE On successful completion, setpgid returns a value of 0. Otherwise, a value of -1 is returned and errno is set to in- dicate the error. ERRORS If any of the following conditions occur, setpgid returns -1 and sets errno to the corresponding value: [EACCESS] pid matches the process ID of a child process of the calling process and the child has suc- cessfully executed one of the exec functions. [EINVAL] The value of pgid is less than 0 or exceeds {PID_MAX}. [EPERM] The process indicated by pid is a session group leader.The value of pid is valid but matches the pro-cess ID of a child of the calling process andthe child process is not in the same sessionas the calling process. The value of pgiddoes not match the process ID of the processindicated by pid and there is no process witha process group ID that matches the value ofpgid in the same session as the calling pro-cess.[ESRCH] pid does not match the process ID of the cal-ling process or of a child process of the cal-ling process.SEE ALSOApril, 1990 1