Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
setsid(2) OSS System Calls Reference Manual
NAME
setsid - Creates a new session and sets the process group ID
LIBRARY
G-series native OSS processes: system library
H-series OSS processes: implicit libraries
SYNOPSIS
#include <sys/types.h> /* optional except for POSIX.1 */
#include <unistd.h>
pid_t setsid(void);
DESCRIPTION
The setsid() function creates a new session when the calling process is not a process group
leader. The calling process then becomes the session leader of this session, the process leader of
a new process group, and has no controlling terminal. The process group ID of the calling pro-
cess is set equal to its process ID. The calling process becomes the only process in the new pro-
cess group and the only process in the new session.
Use From the Guardian Environment
Calls to setsid() from Guardian processes are not successful. Such calls return an errno value of
[ENOTOSS].
RETURN VALUES
Upon successful completion, the value of the new process group ID is returned. If the call was
unsuccessful and initiated by an OSS process, the value -1 is returned and errno is set to indicate
the error. If unsuccessful and initiated by a Guardian process, Guardian trap number 5 is set.
ERRORS
If any of the following conditions occurs, the setsid() function sets errno to the corresponding
value:
[ENOTOSS] The calling process is not an OSS process. The requested operation is not sup-
ported from the Guardian environment.
[EPERM] One of the following conditions exists:
• The calling process is already the process group leader.
• The process group ID of a process other than the calling process matches
the OSS process ID of the calling process.
RELATED INFORMATION
Functions: getpid(2), setpgid(2).
STANDARDS CONFORMANCE
The following are HP extensions to the XPG4 Version 2 specification:
• The errno value [ENOTOSS] can be returned.
7−68 Hewlett-Packard Company 527186-023