Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced Programming in the UNIX Environment Hop Lee.

Similar presentations


Presentation on theme: "Advanced Programming in the UNIX Environment Hop Lee."— Presentation transcript:

1 Advanced Programming in the UNIX Environment Hop Lee

2 Ch06 Process main Function Process Termination Command-Line Arguments Environment List Memory Layout Shared Libraries Memory Allocation Process Identifiers fork Function Family exit Function wait Function Family exec Function Family Process Accounting User Identification Process Times

3 §6.1 main Function A C program starts execution with a function called main: int main(int argc, char *argv[]); When a C program is started by the kernel, a special start-up routine is called before the main function is called. The executable program file specifies this start-up routine as the starting address for the program.

4 This start-up routine get the command-line arguments and the environment from the kernel and sets things up so that the main function is called.

5 §6.2 Process Termination There are five ways for a process to terminate: Normal termination: return from main calling exit calling _exit Abnormal termination: calling abort terminated by a signal

6 exit and _exit Funtions These two functions terminate a program normally: #include void exit(int status ); #include void _exit(int status ); _exit will return to the kernel immediately and exit will perform certain cleanup processing before return to the kernel.

7


Download ppt "Advanced Programming in the UNIX Environment Hop Lee."

Similar presentations


Ads by Google