Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Sessions

A session is a collection of process groups. The session membership of a process is defined by its numeric session ID. A new process inherits its parent’s session ID. The getsid() system call returns the session ID of the process specified by pid.

#define _XOPEN_SOURCE 500
#include <unistd.h>

pid_t getsid(pid_t pid);

Note

Returns session ID of specified process, or (pid_t) -1 on error

If pid is specified as 0, getsid() returns the session ID of the calling process.

Note

On a few UNIX implementations (e.g., HP-UX 11), getsid() can be used to retrieve the session ID of a process only if it is in the same session as the calling process. (SUSv3 permits this possibility.) In other words, the call merely serves, by its success or failure (EPERM), to inform us if the specified process is in the same session as the caller. This restriction doesn’t apply on Linux or on most other implementations.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint