Returns the session ID of the calling process.
pid_t getsid (pid_ t pid)
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.
pid | A process ID of the process being queried. |
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.
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. |
ESRCH | There is no process with a process ID equal to pid. |
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. |
The exec subroutines, fork subroutines, getpid subroutines, setpgid subroutines.