16.11. Process Control
A process is a program that is being executed. Each process has a number of attributes, such as its open files. The exact attributes of processes are dependent on the given system. The standard library's process control features can be divided into two kinds: those for communication with the operating system, and those concerned with signals.
16.11.1. Communication with the Operating System
The functions in Table 16-24 are declared in the header stdio.h, and allow programs to communicate with the operating system.
In Unix and Windows, one attribute of a process is the environment, which consists of a list of strings of the form name=value. Usually, a process inherits an environment generated by its parent process. The getenv( ) function is one way for a program to receive control information, such as the names of directories containing files to use.
In contrast to exit( ), the _Exit( ) function ignores all signals, and does not call any functions registered by atexit( ).
An operating system sends various signals to processes to notify them of unusual events. Such events typically include severe errors, such as illegal memory access, or hardware interrupts such as timer alarms. Signals may also be caused by a user at the console, however, or by the program itself calling the raise( ) function.
Each program may determine for itself how to react to specific signals. A program can choose to ignore signals, or let the default signal handler deal with them, or install its own signal handler function. A signal handler is a function that is executed automatically when the program receives a given type of signal.
The two C functions that deal with signals are declared, along with macros to designate the signal types, in the header signal.h. The functions are listed in Table 16-25.