Session Leader
   HOME

TheInfoList



OR:

In a
POSIX The Portable Operating System Interface (POSIX; ) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines application programming interfaces (APIs), along with comm ...
-conformant
operating system An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ...
, a process group denotes a collection of one or more processes. Among other things, a process group is used to control the distribution of a
signal A signal is both the process and the result of transmission of data over some media accomplished by embedding some variation. Signals are important in multiple subject fields including signal processing, information theory and biology. In ...
; when a signal is directed to a process group, the signal is delivered to each process that is a member of the group. Similarly, a session denotes a collection of one or more process groups. A process may not create a process group that belongs to another session; furthermore, a process is not permitted to join a process group that is a member of another session—that is, a process is not permitted to migrate from one session to another. When a process replaces its image with a new image (by calling one of the exec functions), the new image is subjected to the same process group (and thus session) membership as the old image.


Applications

The distribution of signals to process groups forms the basis of job control employed by shell programs. The TTY device driver incorporates a notion of a foreground process group, to which it sends signals generated by keyboard interrupts, notably
SIGINT Signals intelligence (SIGINT) is the act and field of intelligence-gathering by interception of ''signals'', whether communications between people (communications intelligence—abbreviated to COMINT) or from electronic signals not directly u ...
("interrupt", ), SIGTSTP ("terminal stop", ), and SIGQUIT ("quit", ). It also sends the SIGTTIN and SIGTTOU signals to any processes that attempt to read from or write to the terminal and that are ''not'' in the foreground process group. The shell, in turn, partitions the command
pipelines A pipeline is a system of pipes for long-distance transportation of a liquid or gas, typically to a market area for consumption. The latest data from 2014 gives a total of slightly less than of pipeline in 120 countries around the world. The Un ...
that it creates into process groups, and controls what process group is the foreground process group of its controlling terminal, thus determining what processes (and thus what command pipelines) may perform I/O to and from the terminal at any given time. When the shell forks a new child process for a command pipeline, both the parent shell process and the
child process A child process (CP) in computing is a process created by another process (the parent process). This technique pertains to multitasking operating systems, and is sometimes called a subprocess or traditionally a subtask. There are two major proce ...
immediately make the child process the leader of the process group for the command pipeline. This ensures that the child is the leader of the process group before either the parent or child relies on this being the case. Where a textual user interface is being used on a Unix-like system, sessions are used to implement
login session In computing, a login session is the period of activity between a user logging in and logging out of a (multi-user) system. On Unix and Unix-like operating systems, a login session takes one of two main forms: * When a textual user interface is ...
s. A single process, the session leader, interacts with the controlling terminal in order to ensure that all programs are terminated when a user "hangs up" the terminal connection. (Where a session leader is absent, the processes in the terminal's foreground process group are expected to handle hangups.) Where a
graphical user interface A graphical user interface, or GUI, is a form of user interface that allows user (computing), users to human–computer interaction, interact with electronic devices through Graphics, graphical icon (computing), icons and visual indicators such ...
is being used, the session concept is largely lost, and the
kernel Kernel may refer to: Computing * Kernel (operating system), the central component of most operating systems * Kernel (image processing), a matrix used for image convolution * Compute kernel, in GPGPU programming * Kernel method, in machine learnin ...
's notion of sessions largely ignored. Graphical user interfaces, such as where the X display manager is employed, use a different mechanism for implementing login sessions.


Details

The
system call In computing, a system call (syscall) is the programmatic way in which a computer program requests a service from the operating system on which it is executed. This may include hardware-related services (for example, accessing a hard disk drive ...
setsid is used to create a new session containing a single (new) process group, with the current process as both the session leader and the process group leader of that single process group. Process groups are identified by a positive integer, the process group ID, which is the
process identifier In computing, the process identifier (a.k.a. process ID or PID) is a number used by most operating system kernel (operating system), kernels—such as those of Unix, macOS and Windows—to uniquely identify an active Process (computing), process. ...
of the process that is (or was) the process group leader. Process groups need not necessarily have leaders, although they always begin with one. Sessions are identified by the process group ID of the session leader. POSIX prohibits the change of the process group ID of a session leader. The system call setpgid is used to set the process group ID of a process, thereby either joining the process to an existing process group, or creating a new process group within the session of the process with the process becoming the process group leader of the newly created group. POSIX prohibits the re-use of a process ID where a process group with that identifier still exists (i.e. where the leader of a process group has exited, but other processes in the group still exist). It thereby guarantees that processes may not accidentally become process group leaders. The system call kill is capable of directing signals either to individual processes or to process groups.


See also

*
cgroups cgroups (abbreviated from control groups) is a Linux kernel feature that limits, accounts for, and isolates the resource usage (CPU, memory, disk I/O, etc.) of a collection of processes. Engineers at Google started the work on this feature ...
* Windows Object Manager, specifically
Job objects Work, labor (labour in Commonwealth English), occupation or job is the intentional activity people perform to support the needs and desires of themselves, other people, or organizations. In the context of economics, work can be seen as the huma ...
and associated resource limits


References

*
Single UNIX Specification The Single UNIX Specification (SUS) is a standard for computer operating systems, compliance with which is required to qualify for using the "UNIX" trademark. The standard specifies programming interfaces for the C language, a command-line shell, ...
, Issue 6


Further reading

* {{cite book , title = The Design and Implementation of the FreeBSD Operating System , first1 = Marshall Kirk , last1 = McKusick , first2 = George V. , last2 = Neville-Neil , url = http://www.informit.com/title/0201702452 , date = 2004-08-02 , chapter = FreeBSD Process Management: Process Groups and Sessions , chapter-url = http://www.informit.com/articles/article.aspx?p=366888&seqNum=8 , publisher = Addison Wesley , isbn = 0-201-70245-2
UNIX Signals and Process Groups
Process (computing) POSIX