setsid()

create a new session 

Function


SYNOPSIS

#include <sys/types.h>

#include <unistd.h>

pid_t setsid(void);


DESCRIPTION

The setsid() function creates a new session, if the calling process is not a process group leader. Upon return the calling process is the session leader of this new session, is 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.


PARAMETERS

None.


RETURN VALUES

If successful, setsid() returns the value of the session ID of the calling process. On failure, it returns a value of -1 and sets errno to one of the following values:

EPERM 

The calling process is already a process group leader, or the process group ID of a process that is not the calling process matches the process ID of the calling process.


CONFORMANCE

POSIX.1 (1996)


MULTITHREAD SAFETY LEVEL

Async-signal-safe.


PORTING ISSUES

In Win32, detaching from controlling terminal means the following:

The returned process group ID is the Win32 process ID of the process group leader. Refer to Windows Concepts in the PTC MKS Toolkit UNIX to Windows Porting Guide for more information about process IDs.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
execl(), execle(), execlp(), execv(), execve(), execvp(), fork(), getpgid(), getpid(), getsid(), setpgid(), setpgrp()


PTC MKS Toolkit 10.4 Documentation Build 39.