umm... hi guys.. this is baulin.Am completely new towards system calls.plz give me some info about the job which exit() system call does..

void exit ( int status );

Actually it terminate calling process
Terminates the process normally, performing the regular cleanup for terminating processes.

First, all functions registered by calls to atexit are executed in the reverse order of their registration. Then, all streams are closed and the temporary files deleted, and finally the control is returned to the host environment.

The status argument is returned to the host environment.


Status value returned to the parent process. Generally, a return value of 0 or EXIT_SUCCESS indicates success, and any other value or the constant EXIT_FAILURE is used to indicate an error or some kind of abnormal program termination.

Return Value
It returns nothing

An example is

/* exit example */
#include <stdio.h>
#include <stdlib.h>

int main ()
  FILE * pFile;
  pFile = fopen ("myfile.txt","r");
  if (pFile==NULL)
    printf ("Error opening file");
    exit (1);
    /* file operations here */
  return 0;