setsid(2)
NAME
setsid, setpgrp, setpgrp3 − create session and set process group ID
SYNOPSIS
#include <unistd.h>
pid_t setsid(void);
pid_t setpgrp(void);
pid_t setpgrp3(void);
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, it becomes the process group leader of a new process group, and it 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.
The setpgrp() function is provided for backward compatibility only.
setpgrp3() function is provided for HPUX compatibity in future releases. setpgrp3() is functionally equivalent to setpgrp().
RETURN VALUE
Upon successful completion, setsid() returns the value of the new process group ID of the calling process. Otherwise, it returns a value of −1, and sets errno to indicate the error.
The setpgrp() function returns the value of the process group ID of the calling process.
ERRORS
If setsid() fails, no changes occur, and errno (see errno(2)) is set to one of the following values:
[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.
WARNINGS
The semantics for setpgrp() may change in a future release (see setpgrp3()).
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
setsid(): AES, SVID3, XPG3, XPG4, FIPS 151-2, POSIX.1
setpgrp(): SVID2, SVID3, XPG2
Hewlett-Packard Company — HP-UX Release 10.20: July 1996