Process

From LQWiki
Jump to navigation Jump to search

A process is a concept used by operating systems to describe and manage a running program.

Other words meaning basically the same thing are job and task. Generally, each running program is contained in one process. Some complex programs split their work into multiple processes, each of which contains a small part of the program that performs a specific task.

The ps command is used to list processes on Linux systems. The top command provides a continuously updating list of processes with some resource information at the top of the screen. The list of all processes with parent/child relationships can be displayed with pstree. The jobs command lists the background processes created by the current shell.

The fork() system call is used to create new processes. When this is done, the new process is a child of the old process, which is the parent. If the parent exits, the child is killed. A daemon process reparents itself to be a child of init, so even if the (former) parent quits, the daemon keeps running.

Bash operators

Main article: Bash operators

In bash:

  • the immediate process ID (PID) is represented by $$
  • the parent process ID (PPID) is represented by $PPID
  • the PID of the last process that was sent to background is $!

See also