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. STATUS MESSAEGS AND VALUES On successful completion, setpgid returns a value of 0. Otherwise, a value of -1 is returned and errno is set to indicate the error. If any of the following conditions occur, setpgid returns -1 and sets errno to the corresponding value: EACCES pid matches the process ID of a child process of the calling process and the child has successfully 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 process ID ofa child of the calling process and the child process isnot in the same session as the calling process. Thevalue of pgid does not match the process ID of theprocess indicated by pid and there is no process with aprocess group ID that matches the value of pgid in thesame session as the calling process.ESRCHpid does not match the process ID of the callingprocess or of a child process of the calling process.SEE ALSOJanuary 1992 1