SETPGRP(3) Library Functions Manual SETPGRP(3)

setpgrpset the process group ID


#include <unistd.h>

pid_t setpgrp(void);

If the calling process is not already a session leader, setpgrp () sets the process group ID of the calling process to the process ID of the calling process. If setpgrp () creates a new session, then the new session has no controlling terminal.

The setpgrp () function has no effect when the calling process is a session leader.

Upon completion, setpgrp () shall return the process group ID.

No errors are defined.

None.

It is unspecified whether this function behaves as (0,0) or setsid(3) unless the process is already a session leader. Therefore, applications are encouraged to use setpgid(3) or setsid(3) as appropriate.

None.

The setpgrp () function may be removed in a future version.

exec(3), fork(3), getpid(3), getsid(3), kill(3), setpgid(3), setsid(3)

XBD <unistd.h>

First released in Issue 4, Version 2.

Moved from X/OPEN UNIX extension to BASE.

The setpgrp () function is marked obsolescent.

January 31, 2018 posix.fail