[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Base Operating System and Extensions Technical Reference, Volume 2

setsid Subroutine

Purpose

Creates a session and sets the process group ID.

Library

Standard C Library (libc.a)

Syntax

#include <unistd.h>
pid_t setsid (void)

Description

The setsid subroutine 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, 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 its process ID. The calling process is the only process in the new process group and the only process in the new session.

Return Values

Upon successful completion, the value of the new process group ID is returned. Otherwise, (pid_t) -1 is returned and the errno global variable is set to indicate the error.

Error Codes

The setsid subroutine is unsuccessful if the following is true:

EPERM The calling process is already a process group leader, or the process group ID of a process other than the calling process matches the process ID of the calling process.

Implementation Specifics

This subroutine is part of Base Operating System (BOS) Runtime.

Related Information

The fork subroutine, getpid, getpgrp, or getppid subroutine, setpgid subroutine, setpgrp subroutine.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]