getsid Subroutine

Purpose

Returns the session ID of the calling process.

Library

(libc.a)

Syntax

#include <unistd.h>

pid_t getsid (pid_ t pid)

Description

The getsid subroutine returns the process group ID of the process that is the session leader of the process specified by pid. If pid is equal to pid_t subroutine, it specifies the calling process.

Parameters

Item Description
pid A process ID of the process being queried.

Return Values

Upon successful completion, getsid subroutine returns the process group ID of the session leaded of the specified process. Otherwise, it returns (pid_t)-1 and set errno to indicate the error.

Item Description
id The session ID of the requested process.
-1 Not successful and the errno global variable is set to one of the following error codes.

Error Codes

Item Description
ESRCH There is no process with a process ID equal to pid.
Item Description
EPERM The process specified by pid is not in the same session as the calling process.
ESRCH There is no process with a process ID equal to pid.