[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, 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.

Related Information

The fork subroutine, getpid, getpgrp, or getppid subroutine, setpgid (setpgid or setpgrp Subroutine) subroutine, setpgrp (setpgid or setpgrp Subroutine) subroutine.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]