1 The environment of a Unix process
2 ---------------------------------
4 * When a C program is started by the kernel (by one of the exec functions), a special
5 start-up routine is called before the main function is called. The executable program
6 file specifies this start-up routine as the starting address for the program - this is
7 set up by the link editor when it is invoked vy the C compiler. This start-up routine
8 takes values from the kernel (the command-line arguments and the environment and sets
9 things up so that the main function is called as shown:
11 int main(int argc, char *argv[]);
13 1. Process Termination
14 ----------------------
16 There are five ways for a process to terminate
23 2. Abnormal termination
25 (b) terminated by a signal
27 The start-up routine is also written so that if the main function returns, the exit
30 The difference between exit() and _exit() is that _exit() returns directly to the
31 kernel, and exit() performs some cleanup before returning to the kernel (by calling
34 --> atexit function allows one to register handlers functions to be called by exit(),
35 _before_ the cleanup is done