getsid(2) — System Calls
NAME
getsid − retrieves the session ID of a process
SYNOPSIS
#include <sys/types.h>
pid_t getsid (
pid_t pid);
PARAMETERS
pidSpecifies the process ID of a process.
DESCRIPTION
To obtain the session ID of a process, the getsid function searches for a process with a process ID equivalent to the pid parameter. If the pid parameter is equivalent to (pid_t)0, the session ID of the calling process is retrieved by the getsid function.
RETURN VALUES
The getsid function returns the session ID of the targeted process on success. If the operation is not successful, a value of (pid_t)-1 is returned, and errno is set to indicate the error.
ERRORS
If an error occurs, errno is set as follows:
[EPERM]Specifies that the process with a process ID equal to the value pid is not in the same session as the calling process. The calling process does not have access to that process.
[ESRCH]Specifies that a process with process ID specified by the pid parameter cannot be located.
RELATED INFORMATION
Functions: exec(2), fork(2), getpid(2), setpgid(2), setsid(2).