O'Reilly logo

C Pocket Reference by Ulla Kirch-Prinz, Peter Prinz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Process Control

A process is a program that is being executed. The attributes that a process can have vary from one operating system to another. For this reason, the process control functions work in ways that are specific to certain systems.

Communication with the Operating System

Environment

In operating systems such as Unix and Windows, each process is started in an environment represented by a list of strings with the form NAME = VALUE. These "environment variables" can be read using the function getenv() .

System calls

The function system() invokes the system's command interpreter and gives it a command to execute.

Program termination

A C program is normally terminated via a call to the function exit() , or by a return statement in the function main() . On normal termination, the following actions are performed:

  1. Any functions that have been installed by atexit() are executed.

  2. The I/O buffers are flushed and the files closed.

  3. The files created by tmpfile() are deleted.

The function abort() , on the other hand, ends a C program without performing the actions just listed. This function does produce an error message announcing that the program was aborted, however.

The function exit() can be called with one of the constants EXIT_FAILURE and EXIT_SUCCESS , defined in stdlib.h, as an argument. In this way the program can inform its parent process whether it "failed" or "succeeded."

All of the functions described in this section are declared in the header file stdlib.h.

Signals

The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required