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 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 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 is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines system and user-level application programming interfaces (APIs), 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/IEC JTC 1/SC 22/WG 15 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.

pwd Directory information command on various operating systems

In Unix-like and some other operating systems, the pwd command writes the full pathname of the current working directory to the standard output.

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.

In computing, particularly in the context of the Unix operating system and its workalikes, fork is an operation whereby a process creates a copy of itself. It is an interface which is required for compliance with the POSIX and Single UNIX Specification standards. It is usually implemented as a C standard library wrapper to the fork, clone, or other system calls of the kernel. Fork is the primary method of process creation on Unix-like operating systems.

<span class="mw-page-title-main">GNU Screen</span> Terminal multiplexer software

GNU Screen is a terminal multiplexer: a software application that can be used to multiplex several virtual consoles, allowing a user to access multiple separate login sessions inside a single terminal window, or detach and reattach sessions from a terminal. It is useful for dealing with multiple programs from a command line interface, and for separating programs from the session of the Unix shell that started the program, particularly so a remote process continues running even when the user is disconnected.

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. The related Unix utility top provides a real-time view of the running processes.

<span class="mw-page-title-main">Pseudoterminal</span> Pair of pseudo-device endpoints

In some operating systems, including Unix-like systems, 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.

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 shell 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. It was originally designed to notify the process of a serial line drop. SIGHUP is a symbolic constant defined in the header file signal.h.

In computer networking, STREAMS is the native framework in Unix System V for implementing character device drivers, network protocols, and inter-process communication. In this framework, a stream is a chain of coroutines that pass messages between a program and a device driver. STREAMS originated in Version 8 Research Unix, as Streams.

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.

<span class="mw-page-title-main">Unix-like</span> Operating system that behaves similarly to Unix, e.g. Linux

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. Although there are general philosophies for Unix design, there is no technical standard defining the term, and opinions can differ about the degree to which a particular operating system or application is Unix-like.

<span class="mw-page-title-main">Unix</span> Family of computer operating systems

Unix is a family of multitasking, multi-user 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.

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 (7 January 2021). "Job Objects - Win32 apps". docs.microsoft.com. Retrieved 2022-08-28.

Further reading