Misplaced Pages

Job control (Unix)

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.

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 ( batch processing ).

#507492

69-474: When using Unix or Unix-like operating systems via a terminal (or terminal emulator ), a user will initially only have a single process running, their interactive shell (it may or may not be a login shell). Most tasks (directory listing, editing files, etc.) can easily be accomplished by letting the program take control of the terminal and returning control to the shell when the program exits – formally, by attaching to standard input and standard output to

138-455: A terminal to a mainframe system via a serial line and the RS-232 protocol . When a system of software interrupts , called signals, was being developed, one of those signals was designated for use on hangup. SIGHUP would be sent to programs when the serial line was dropped, often because the connected user terminated the connection by hanging up the modem . The system would detect the line

207-429: A time-sharing configuration, as well as portability. Unix systems are characterized by various concepts: the use of plain text for storing data; a hierarchical file system ; treating devices and certain types of inter-process communication (IPC) as files; and the use of a large number of software tools , small programs that can be strung together through a command-line interpreter using pipes , as opposed to using

276-484: A time-sharing operating system for the GE 645 mainframe computer. Multics featured several innovations , but also presented severe problems. Frustrated by the size and complexity of Multics, but not by its goals, individual researchers at Bell Labs started withdrawing from the project. The last to leave were Ken Thompson , Dennis Ritchie , Douglas McIlroy , and Joe Ossanna , who decided to reimplement their experiences in

345-519: A 1999 interview, Dennis Ritchie voiced his opinion that Linux and BSD Unix operating systems are a continuation of the basis of the Unix design and are derivatives of Unix: I think the Linux phenomenon is quite delightful, because it draws so strongly on the basis that Unix provided. Linux seems to be among the healthiest of the direct Unix derivatives, though there are also the various BSD systems as well as

414-535: A background job with the bg builtin , or as the foreground job with fg . In either case, the shell redirects I/O appropriately, and sends the SIGCONT signal to the process, which causes the operating system to resume its execution. In Bash , a program can be started as a background job by appending an ampersand ( & ) to the command line; its output is directed to the terminal (potentially interleaved with other programs' output), but it cannot read from

483-460: A convenient platform for programmers developing software to be run on it and on other systems, rather than for non-programmers. The system grew larger as the operating system started spreading in academic circles, and as users added their own tools to the system and shared them with colleagues. At first, Unix was not designed to support multi-tasking or to be portable . Later, Unix gradually gained multi-tasking and multi-user capabilities in

552-468: A generic term such as system to help avoid the creation of a genericized trademark . SIGHUP On POSIX -compliant platforms, SIGHUP (" sig nal h ang up ") 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 . Access to computer systems for many years consisted of connecting

621-405: A new project of smaller scale. This new operating system was initially without organizational backing, and also without a name. The new operating system was a single-tasking system. In 1970, the group coined the name Unics for Uniplexed Information and Computing Service as a pun on Multics , which stood for Multiplexed Information and Computer Services . Brian Kernighan takes credit for

690-512: A potential universal operating system, suitable for computers of all sizes. The Unix environment and the client–server program model were essential elements in the development of the Internet and the reshaping of computing as centered in networks rather than in individual computers. Both Unix and the C programming language were developed by AT&T and distributed to government and academic institutions, which led to both being ported to

759-420: A reference directory layout for Unix-like operating systems; it has mainly been used in Linux. The Unix system is composed of several components that were originally packaged together. By including the development environment, libraries, documents and the portable, modifiable source code for all of these components, in addition to the kernel of an operating system, Unix was a self-contained software system. This

SECTION 10

#1732791346508

828-504: A representation like Un*x , *NIX , or *N?X is used to indicate all operating systems similar to Unix. This comes from the use of the asterisk ( * ) and the question mark characters as wildcard indicators in many utilities. This notation is also used to describe other Unix-like systems that have not met the requirements for UNIX branding from the Open Group. The Open Group requests that UNIX always be used as an adjective followed by

897-449: A set of cultural norms for developing software, norms which became as important and influential as the technology of Unix itself; this has been termed the Unix philosophy . The TCP/IP networking protocols were quickly implemented on the Unix versions widely used on relatively inexpensive computers, which contributed to the Internet explosion of worldwide, real-time connectivity and formed

966-414: A signal to re-read configuration files , or reinitialize. This convention survives to this day in packages such as Apache and Sendmail . With the decline of access via serial line, the meaning of SIGHUP has changed somewhat on modern systems, often meaning a controlling pseudo or virtual terminal has been closed. If a command is executed inside a terminal window and the terminal window is closed while

1035-487: A single monolithic program that includes all of the same functionality. These concepts are collectively known as the " Unix philosophy ". Brian Kernighan and Rob Pike summarize this in The Unix Programming Environment as "the idea that the power of a system comes more from the relationships among programs than from the programs themselves". By the early 1980s, users began seeing Unix as

1104-544: A single nine-track magnetic tape , earning its reputation as a portable system. The printed documentation, typeset from the online sources, was contained in two volumes. The names and filesystem locations of the Unix components have changed substantially across the history of the system. Nonetheless, the V7 implementation has the canonical early structure: The Unix system had a significant impact on other operating systems. It achieved its reputation by its interactivity, by providing

1173-479: A uniform interface, but at the expense of occasionally requiring additional mechanisms such as ioctl and mode flags to access features of the hardware that did not fit the simple "stream of bytes" model. The Plan 9 operating system pushed this model even further and eliminated the need for additional mechanisms. Unix also popularized the hierarchical file system with arbitrarily nested subdirectories, originally introduced by Multics. Other common operating systems of

1242-508: A versatile document preparation system, and an efficient file system featuring sophisticated access control, mountable and de-mountable volumes, and a unified treatment of peripherals as special files ." The latter permitted the Network Control Program (NCP) to be integrated within the Unix file system, treating network connections as special files that could be accessed through standard Unix I/O calls , which included

1311-402: A wider variety of machine families than any other operating system. The Unix operating system consists of many libraries and utilities along with the master control program, the kernel . The kernel provides services to start and stop programs, handles the file system and other common "low-level" tasks that most programs share, and schedules access to avoid conflicts when programs try to access

1380-429: Is receiving input from the terminal is "in the foreground". Job control is a facility developed to make this possible, by allowing the user to start processes in the background, send already running processes into the background, bring background processes into the foreground, and suspend or terminate processes. The concept of a job maps the (shell) concept of a single shell command to the (operating system) concept of

1449-453: Is returned to the shell. However, a process can register a signal handler for or ignore SIGTSTP. A process can also be paused with the "stop" signal ( SIGSTOP ), which cannot be caught or ignored. A job running in the foreground can be interrupted by typing the interruption character ( Ctrl-C ). This sends the "interrupt" signal ( SIGINT ), which defaults to terminating the process, though it can be overridden. A stopped job can be resumed as

SECTION 20

#1732791346508

1518-472: Is used so the processes are adopted by init (the kernel sets their parent process to init) and continue executing as daemons . Alternatives to prevent jobs from being terminated include nohup and using a terminal multiplexer . A job running in the foreground can be stopped by typing the suspend character ( Ctrl-Z ). This sends the "terminal stop" signal ( SIGTSTP ) to the process group. By default, SIGTSTP causes processes receiving it to stop, and control

1587-484: The kill builtin (not /bin/kill ) can signal jobs by job ID as well as by process group ID – sending a signal to a job sends it to the whole process group, and jobs specified by a job ID should be killed by prefixing % . kill can send any signal to a job; however, if the intent is to rid the system of the processes the signals SIGKILL and SIGTERM (the default) are probably the most applicable. Unix Early research and development: Merging

1656-609: The Bell Labs research center by Ken Thompson , Dennis Ritchie , and others. Initially intended for use inside the Bell System , AT&T licensed Unix to outside parties in the late 1970s, leading to a variety of both academic and commercial Unix variants from vendors including University of California, Berkeley ( BSD ), Microsoft ( Xenix ), Sun Microsystems ( SunOS / Solaris ), HP / HPE ( HP-UX ), and IBM ( AIX ). Early versions of Unix ran on PDP-11 computers; Unix

1725-782: The GNU Compiler Collection (and the rest of the GNU toolchain ), the GNU C library and the GNU Core Utilities  – have gone on to play central roles in other free Unix systems as well. Linux distributions , consisting of the Linux kernel and large collections of compatible software have become popular both with individual users and in business. Popular distributions include Red Hat Enterprise Linux , Fedora , SUSE Linux Enterprise , openSUSE , Debian , Ubuntu , Linux Mint , Slackware Linux , Arch Linux and Gentoo . A free derivative of BSD Unix, 386BSD ,

1794-615: The Single UNIX Specification describes a shell utility called nohup , which can be used as a wrapper to start a program and make it ignore SIGHUP by default. Secondly, child process groups can be "disowned" by invoking disown with the job id , which removes the process group from the shell's job table (so they will not be sent SIGHUP), or (optionally) keeps them in the job table but prevents them from receiving SIGHUP on shell termination. Different shells also have other methods of controlling and managing SIGHUP, such as

1863-586: The UNIX 98 or UNIX 03 trademarks today, after the operating system's vendor pays a substantial certification fee and annual trademark royalties to The Open Group. Systems that have been licensed to use the UNIX trademark include AIX , EulerOS , HP-UX , Inspur K-UX , IRIX , macOS , Solaris , Tru64 UNIX (formerly "Digital UNIX", or OSF/1 ), and z/OS . Notably, EulerOS and Inspur K-UX are Linux distributions certified as UNIX 03 compliant. Sometimes

1932-496: The disown facility of ksh . Most modern Linux distributions documentation specify using kill -HUP <processID> to send the SIGHUP signal. Daemon programs sometimes use SIGHUP as a signal to restart themselves, the most common reason for this being to re-read a configuration file that has been changed. Symbolic signal names are used because signal numbers can vary across platforms, but XSI -conformant systems allow

2001-472: The (%-prefixed) job ID as the jobspec. Job control and job IDs are typically only used in interactive use, where they simplify referring to process groups; in scripting PGIDs are used instead, as they are more precise and robust, and indeed job control is disabled by default in bash scripts. Job control was first implemented in the C shell by Jim Kulp, then at IIASA in Austria, making use of features of

2070-553: The 4.1 BSD kernel. The KornShell , developed at Bell Labs, adopted it and it was later incorporated into the SVR4 version of the Bourne shell , and exists in most modern Unix shells. The POSIX standard specifies two commands for resuming suspended jobs in the background and foreground, respectively bg and fg . These were modeled after the Korn shell job control commands. Typically,

2139-487: The Open Group Base Specification. In 1999, in an effort towards compatibility, several Unix system vendors agreed on SVR4's Executable and Linkable Format (ELF) as the standard for binary and object code files. The common format allows substantial binary compatibility among different Unix systems operating on the same CPU architecture. The Filesystem Hierarchy Standard was created to provide

Job control (Unix) - Misplaced Pages Continue

2208-413: The UNIX trademark to The Open Group , an industry consortium founded in 1996. The Open Group allows the use of the mark for certified operating systems that comply with the Single UNIX Specification (SUS). Unix-like operating systems have been relevant since the 1990s which function similarly to Unix: popular examples are GNU (including Linux ), FreeBSD and macOS . Unix was originally meant to be

2277-632: The added benefit of closing all connections on program exit, should the user neglect to do so. In order "to minimize the amount of code added to the basic Unix kernel ", much of the NCP code ran in a swappable user process, running only when needed. In October 1993, Novell , the company that owned the rights to the Unix System V source at the time, transferred the trademarks of Unix to the X/Open Company (now The Open Group ), and in 1995 sold

2346-465: The basis for a widely implemented operating system interface standard (POSIX, see above). The C programming language soon spread beyond Unix, and is now ubiquitous in systems and applications programming. Early Unix developers were important in bringing the concepts of modularity and reusability into software engineering practice, spawning a "software tools" movement. Over time, the leading developers of Unix (and programs that ran on it) established

2415-435: The basis for implementations on many other platforms. The Unix policy of extensive on-line documentation and (for many years) ready access to all system source code raised programmer expectations, and contributed to the launch of the free software movement in 1983. In 1983, Richard Stallman announced the GNU (short for "GNU's Not Unix") project, an ambitious effort to create a free software Unix-like system—"free" in

2484-492: The command interpreter an ordinary user-level program, with additional commands provided as separate programs, was another Multics innovation popularized by Unix. The Unix shell used the same language for interactive commands as for scripting ( shell scripts  – there was no separate job control language like IBM's JCL ). Since the shell and OS commands were "just another program", the user could choose (or even write) their own shell. New commands could be added without changing

2553-441: The command process is still running, it receives SIGHUP. If the process receiving SIGHUP is a Unix shell , then as part of job control it will often intercept the signal and ensure that all stopped processes are continued before sending the signal to child processes (more precisely, process groups , represented internally by the shell as a "job"), which by default terminates them. This can be circumvented in two ways. Firstly,

2622-479: The core of the Mac OS X operating system, later renamed macOS . Unix-like operating systems are widely used in modern servers , workstations , and mobile devices . In the late 1980s, an open operating system standardization effort now known as POSIX provided a common baseline for all operating systems; IEEE based POSIX around the common structure of the major competing variants of the Unix system, publishing

2691-546: The era had ways to divide a storage device into multiple directories or sections, but they had a fixed number of levels, often only one level. Several major proprietary operating systems eventually added recursive subdirectory capabilities also patterned after Multics. DEC's RSX-11M 's "group, user" hierarchy evolved into OpenVMS directories, CP/M 's volumes evolved into MS-DOS 2.0+ subdirectories, and HP's MPE group.account hierarchy and IBM's SSP and OS/400 library systems were folded into broader POSIX file systems. Making

2760-679: The first POSIX standard in 1988. In the early 1990s, a separate but very similar effort was started by an industry consortium, the Common Open Software Environment (COSE) initiative, which eventually became the Single UNIX Specification (SUS) administered by The Open Group . Starting in 1998, the Open Group and IEEE started the Austin Group , to provide a common definition of POSIX and the Single UNIX Specification, which, by 2008, had become

2829-420: The idea, but adds that "no one can remember" the origin of the final spelling Unix . Dennis Ritchie, Doug McIlroy, and Peter G. Neumann also credit Kernighan. The operating system was originally written in assembly language , but in 1973, Version 4 Unix was rewritten in C . Version 4 Unix, however, still had much PDP-11 specific code, and was not suitable for porting. The first port to another platform

Job control (Unix) - Misplaced Pages Continue

2898-476: The late 1970s and early 1980s, the influence of Unix in academic circles led to large-scale adoption of Unix ( BSD and System V ) by commercial startups, which in turn led to Unix fragmenting into multiple, similar — but often slightly and mutually incompatible — systems including DYNIX , HP-UX , SunOS / Solaris , AIX , and Xenix . In the late 1980s, AT&T Unix System Laboratories and Sun Microsystems developed System V Release 4 ( SVR4 ), which

2967-428: The modular design of the Unix model, sharing components is relatively common: most or all Unix and Unix-like systems include at least some BSD code, while some include GNU utilities in their distributions. Linux and BSD Unix are increasingly filling market needs traditionally served by proprietary Unix operating systems, expanding into new markets such as the consumer desktop , mobile devices and embedded devices . In

3036-443: The more official offerings from the workstation and mainframe manufacturers. In the same interview, he states that he views both Unix and Linux as "the continuation of ideas that were started by Ken and me and many others, many years ago". OpenSolaris was the free software counterpart to Solaris developed by Sun Microsystems , which included a CDDL -licensed kernel and a primarily GNU userland. However, Oracle discontinued

3105-497: The networks and creating the Internet: Commercialization, privatization, broader access leads to the modern Internet: Examples of Internet services: Unix ( / ˈ j uː n ɪ k s / , YOO -niks ; trademarked as 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

3174-475: The operating system should provide a set of simple tools, each of which performs a limited, well-defined function. A unified and inode -based filesystem and an inter-process communication mechanism known as " pipes " serve as the main means of communication, and a shell scripting and command language (the Unix shell ) is used to combine the tools to perform complex workflows. In the early 1990s, AT&T sold its rights in Unix to Novell , which then sold

3243-503: The original version of Unix – the entire system was configured using textual shell command scripts. The common denominator in the I/O system was the byte – unlike "record-based" file systems . The focus on text for representing nearly everything made Unix pipes especially useful and encouraged the development of simple, general tools that could easily be combined to perform more complicated ad hoc tasks. The focus on text and bytes made

3312-486: The possibly many processes that the command entails. Multi-process tasks come about because processes may create additional child processes, and a single shell command may consist of a pipeline of multiple communicating processes. For example, a command to select lines containing the text "title", sort these alphabetically, and display the result in a pager . This creates at least three processes: one for grep , one for sort , and one for less . Job control allows

3381-599: The project upon their acquisition of Sun, which prompted a group of former Sun employees and members of the OpenSolaris community to fork OpenSolaris into the illumos kernel. As of 2014, illumos remains the only active, open-source System V derivative. In May 1975, RFC 681 described the development of Network Unix by the Center for Advanced Computation at the University of Illinois Urbana-Champaign . The Unix system

3450-591: The related business operations to Santa Cruz Operation (SCO). Whether Novell also sold the copyrights to the actual software was the subject of a federal lawsuit in 2006, SCO v. Novell , which Novell won. The case was appealed, but on August 30, 2011, the United States Court of Appeals for the Tenth Circuit affirmed the trial decisions, closing the case. Unix vendor SCO Group Inc. accused Novell of slander of title . The present owner of

3519-436: The same process group. A job can be referred to by a handle called the job control job ID or simply job ID , which is used by shell builtins to refer to the job. Job IDs begin with the % character; %n identifies job n , while %% identifies the current job. Other job IDs are specified by POSIX . In informal usage the number may be referred to as the "job number" or "job ID", and Bash documentation refers to

SECTION 50

#1732791346508

3588-482: The same resource or device simultaneously. To mediate such access, the kernel has special rights, reflected in the distinction of kernel space from user space , the latter being a lower priority realm where most application programs operate. The origins of Unix date back to the mid-1960s when the Massachusetts Institute of Technology , Bell Labs , and General Electric were developing Multics ,

3657-535: The sense that everyone who received a copy would be free to use, study, modify, and redistribute it. The GNU project's own kernel development project, GNU Hurd , had not yet produced a working kernel, but in 1991 Linus Torvalds released the Linux kernel as free software under the GNU General Public License . In addition to their use in the GNU operating system, many GNU packages – such as

3726-427: The shell itself. Unix's innovative command-line syntax for creating modular chains of producer-consumer processes ( pipelines ) made a powerful programming paradigm ( coroutines ) widely available. Many later command-line interpreters have been inspired by the Unix shell. A fundamental simplifying assumption of Unix was its focus on newline - delimited text for nearly all file formats. There were no "binary" editors in

3795-426: The shell keeps a list of jobs in a job table . Recall that a job corresponds to a process group, which consists of all the members of a pipeline and their descendants. The jobs command will list the background jobs existing in the job table, along with their job number and job state (stopped or running). When a session ends when the user logs out (exits the shell, which terminates the session leader process),

3864-416: The shell process sends SIGHUP to all jobs, and waits for the process groups to end before terminating itself. The disown command can be used to remove jobs from the job table, so that when the session ends the child process groups are not sent SIGHUP, nor does the shell wait for them to terminate. They thus become orphan processes , and may be terminated by the operating system, though more often this

3933-517: The shell to control these related processes as one entity, and when a user issues the appropriate key combination (usually Control + Z ), the entire group of processes gets suspended. Jobs are managed by the operating system as a single process group , and the job is the shell's internal representation of such a group. This is defined in POSIX as: A set of processes, comprising a shell pipeline, and any processes descended from it, that are all in

4002-412: The shell, which reads or writes from the terminal, and catching signals sent from the keyboard, like the termination signal resulting from pressing Control + C . However, sometimes the user will wish to carry out a task while using the terminal for another purpose. A task that is running but is not receiving input from the terminal is said to be running "in the background", while the single task that

4071-654: The software at a nominal fee for educational use, by running on inexpensive hardware, and by being easy to adapt and move to different machines. Unix was originally written in assembly language , but was soon rewritten in C , a high-level programming language . Although this followed the lead of CTSS , Multics and Burroughs MCP , it was Unix that popularized the idea. Unix had a drastically simplified file model compared to many contemporary operating systems: treating all kinds of files as simple byte arrays. The file system hierarchy contained machine services and devices (such as printers , terminals , or disk drives ), providing

4140-418: The system far more scalable and portable than other systems. Over time, text-based applications have also proven popular in application areas, such as printing languages ( PostScript , ODF ), and at the application layer of the Internet protocols , e.g., FTP , SMTP , HTTP , SOAP , and SIP . Unix popularized a syntax for regular expressions that found widespread use. The Unix programming interface became

4209-437: The terminal input. A background process that attempts to read from or write to its controlling terminal is sent a SIGTTIN (for input) or SIGTTOU (for output) signal. These signals stop the process by default, but they may also be handled in other ways. Shells often override the default stop action of SIGTTOU so that background processes deliver their output to the controlling terminal by default. In Bash-compatible shells,

SECTION 60

#1732791346508

4278-459: The trademark UNIX is The Open Group, an industry standards consortium. Only systems fully compliant with and certified to the Single UNIX Specification qualify as "UNIX" (others are called " Unix-like "). By decree of The Open Group, the term "UNIX" refers more to a class of operating systems than to a specific implementation of an operating system; those operating systems which meet The Open Group's Single UNIX Specification should be able to bear

4347-536: Was a port of Version 6, made four years later (1977) at the University of Wollongong for the Interdata 7/32 , followed by a Bell Labs port of Version 7 to the Interdata 8/32 during 1977 and 1978. Bell Labs produced several versions of Unix that are collectively referred to as Research Unix . In 1975, the first source license for UNIX was sold to Donald B. Gillies at the University of Illinois Urbana–Champaign (UIUC) Department of Computer Science. During

4416-431: Was commonly used on minicomputers and mainframes from the 1970s onwards. It distinguished itself from its predecessors as the first portable operating system: almost the entire operating system is written in the C programming language , which allows Unix to operate on numerous platforms. Unix systems are characterized by a modular design that is sometimes called the " Unix philosophy ". According to this philosophy,

4485-457: Was dropped via the lost Data Carrier Detect (DCD) signal. Signals have always been a convenient method of inter-process communication (IPC), but in early implementations there were no user-definable signals (such as the later additions of SIGUSR1 and SIGUSR2 ) that programs could intercept and interpret for their own purposes. For this reason, applications that did not require a controlling terminal, such as daemons , would re-purpose SIGHUP as

4554-402: Was one of the key reasons it emerged as an important teaching and learning tool and has had a broad influence. See § Impact , below. The inclusion of these components did not make the system large – the original V7 UNIX distribution, consisting of copies of all of the compiled binaries plus all of the source code and documentation occupied less than 10 MB and arrived on

4623-573: Was released in 1992 and led to the NetBSD and FreeBSD projects. With the 1994 settlement of a lawsuit brought against the University of California and Berkeley Software Design Inc. ( USL v. BSDi ) by Unix System Laboratories , it was clarified that Berkeley had the right to distribute BSD Unix for free if it so desired. Since then, BSD Unix has been developed in several different product branches, including OpenBSD and DragonFly BSD . Because of

4692-516: Was said to "present several interesting capabilities as an ARPANET mini-host". At the time, Unix required a license from Bell Telephone Laboratories that cost US$ 20,000 for non-university institutions, while universities could obtain a license for a nominal fee of $ 150. It was noted that Bell was "open to suggestions" for an ARPANET-wide license. The RFC specifically mentions that Unix "offers powerful local processing facilities in terms of user programs, several compilers , an editor based on QED ,

4761-404: Was subsequently adopted by many commercial Unix vendors. In the 1990s, Unix and Unix-like systems grew in popularity and became the operating system of choice for over 90% of the world's top 500 fastest supercomputers , as BSD and Linux distributions were developed through collaboration by a worldwide network of programmers. In 2000, Apple released Darwin , also a Unix system, which became

#507492