Process group

Last updated

In a POSIX-conformant operating system, a process group denotes a collection of one or more processes. [1] Among other things, a process group is used to control the distribution of a signal; when a signal is directed to a process group, the signal is delivered to each process that is a member of the group. [2]

Contents

Similarly, a session denotes a collection of one or more process groups. [3] 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 sessionthat 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 ("interrupt", Control+C), SIGTSTP ("terminal stop", Control+Z), and SIGQUIT ("quit", Control+\). 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 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 immediately make the child process into the leader of the process group for the command pipeline. In this way, it is ensured that the child is the leader of the process group before either the parent or the 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 sessions . 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 is being used, the session concept is largely lost, and the kernel'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 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. [4] Process groups are identified by a positive integer, the process group ID, which is the process identifier 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. [5] 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. [2]

See also

Related Research Articles

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 both the system- and user-level application programming interfaces (API), along with command line shells and utility interfaces, for software compatibility (portability) with variants of Unix and other operating systems. POSIX is also a trademark of the IEEE. POSIX is intended to be used by both application and system developers.

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, and user commands. The core specifications of the SUS known as Base Specifications are developed and maintained by the Austin Group, which is a joint working group of IEEE, ISO JTC 1 SC22 and The Open Group. If an operating system is submitted to The Open Group for certification, and passes conformance tests, then it is deemed to be compliant with a UNIX standard such as UNIX 98 or UNIX 03.

A background process is a computer process that runs behind the scenes and without user intervention. Typical tasks for these processes include logging, system monitoring, scheduling, and user notification. The background process usually is a child process created by a control process for processing a computing task. After creation, the child process will run on its own, performing the task independent of the control process, freeing the control process of performing that task.

The printing subsystem of UNIX System V is one of several standardized systems for printing on Unix, and is typical of commercial System V-based Unix versions such as Solaris and SCO OpenServer. A system running this print architecture could traditionally be identified by the use of the user command lp as the primary interface to the print system, as opposed to the BSD lpr command.

ps (Unix) Standard UNIX utility that displays the currently-running processes

In most Unix and Unix-like operating systems, the ps program displays the currently-running processes. A related Unix utility named top provides a real-time view of the running processes.

Pseudoterminal

In some operating systems, including Unix and Linux, a pseudoterminal, pseudotty, or PTY is a pair of pseudo-device endpoints (files) which establish asynchronous, bidirectional communication (IPC) channel between two or more processes. The master provides means by which a terminal emulator process controls the slave. The slave, emulates a hardware text terminal device. PTY are similar to bidirectional pipes.

An orphan process is a computer process whose parent process has finished or terminated, though it remains running itself.

Signals are standardized messages sent to a running program to trigger specific behavior, such as quitting or error handling. They are a limited form of inter-process communication (IPC), typically used in Unix, Unix-like, and other POSIX-compliant operating systems.

In computing, kill is a command that is used in several popular operating systems to send signals to running processes.

who (Unix)

The standard Unix command who displays a list of users who are currently logged into the computer.

Unix-like operating systems identify a user by a value called a user identifier, often abbreviated to user ID or UID. The UID, along with the group identifier (GID) and other access control criteria, is used to determine which system resources a user can access. The password file maps textual user names to UIDs. UIDs are stored in the inodes of the Unix file system, running processes, tar archives, and the now-obsolete Network Information Service. In POSIX-compliant environments, the command-line command id gives the current user's UID, as well as more information such as the user name, primary user group and group identifier (GID).

On POSIX-compliant platforms, SIGHUP is a signal sent to a process when its controlling terminal is closed. SIGHUP is a symbolic constant defined in the header file signal.h.

Comparison of command shells Wikimedia list article

A command shell is a command-line interface to interact with and manipulate a computer's operating system.

In computing, sleep is a command in Unix, Unix-like and other operating systems that suspends program execution for a specified time.

In Unix and Unix-like operating systems, job control refers to control of jobs by a shell, especially interactively, where a "job" is a shell's representation for a process group. Basic job control features are the suspending, resuming, or terminating of all processes in the job/process group; more advanced features can be performed by sending signals to the job. Job control is of particular interest in Unix due to its multiprocessing, and should be distinguished from job control generally, which is frequently applied to sequential execution.

The Unix command fuser is used to show which processes are using a specified computer file, file system, or Unix socket.

Unix-like Operating system that behaves in a manner similar to a Unix system

A Unix-like operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Unix-like application is one that behaves like the corresponding Unix command or shell. There is no technical standard defining the term, and opinions can differ about whether or the degree to which a particular operating system or application is Unix-like.

Unix Family of computer operating systems that derive from the original AT&T Unix

Unix is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and others.

In Unix and Unix-like operating systems, printf is a shell builtin that formats and prints data.

The POSIX terminal interface is the generalized abstraction, comprising both an Application Programming Interface for programs, and a set of behavioural expectations for users of a terminal, as defined by the POSIX standard and the Single Unix Specification. It is a historical development from the terminal interfaces of BSD version 4 and Seventh Edition Unix.

References

  1. IEEE and The Open Group (2018). "3. Definitions". The Open Group Base Specifications Issue 7. § 296. Retrieved 2020-08-30. A collection of processes that permits the signaling of related processes.
  2. 1 2 kill   System Interfaces Reference, The Single UNIX Specification , Version 4 from The Open Group
  3. IEEE and The Open Group (2018). "3. Definitions". The Open Group Base Specifications Issue 7. § 343. Retrieved 2020-08-30. A collection of process groups [...]. Each process group is a member of a session.
  4. setsid   System Interfaces Reference, The Single UNIX Specification , Version 4 from The Open Group
  5. setpgid   System Interfaces Reference, The Single UNIX Specification , Version 4 from The Open Group
  6. Karl-Bridge-Microsoft. "Job Objects - Win32 apps". docs.microsoft.com. Retrieved 2022-08-28.

Further reading