SETSID(2)
NAME
setsid, setpgrp − create session and set process group ID
SYNOPSIS
#include <sys/types.h>
pid_t setsid()
pid_t setpgrp()
DESCRIPTION
If the calling process is not a process group leader, setsid or setpgrp creates a new session. The calling process becomes the session leader of this new session, becomes the process group leader of a new process group, and has no controlling terminal. The process group ID of the calling process is set equal to the process ID of the calling process. The calling process is the only process in the new process group, and the only process in the new session.
Setpgrp is provided for backward compatibility only.
ERRORS
No change occurs if any of the following conditions occur. In addition, setsid fails with the following errors:
[EPERM] The calling process is already a process group leader.
[EPERM]
The process group ID of a process other than the calling process matches the process ID of the calling process.
RETURN VALUE
Setpgrp returns the value of the process group ID of the calling process.
Upon successful completion, setsid returns the value of the new process group ID of the calling process. Otherwise, a value of −1 is returned and errno is set to indicate the error.
AUTHOR
Setpgrp and setsid were developed by HP and AT&T.
SEE ALSO
exec(2), exit(2), fork(2), getpid(2), kill(2), setpgid(2), signal(2), termio(7).
STANDARDS CONFORMANCE
setpgrp: SVID2, XPG2
setsid: XPG3, POSIX.1, FIPS 151-1
Hewlett-Packard Company — HP-UX Release 7.0: Sept 1989