C Library Functions -exit()

C Standard Library - <stdlib.h>

Description

C Library Functionsvoid exit(int status)Immediately terminates the calling process. Any open file descriptors belonging to this process are closed, and the process's child processes are inherited by process 1, init, while a SIGCHLD signal is sent to the parent process.

Declaration

Below is the declaration of the exit() function.

void exit(int status)

Parameter

  • status-- Status value returned to the parent process.

Return Value

This function does not return a value.

Example

The following example demonstrates the usage of the exit() function.

Example

#include <stdio.h>
#include <stdlib.h>

int main ()
{
   printf("Program start....\n");
   
   printf("Program exit....\n");
   exit(0);

   printf("Program end....\n");

   return(0);
}

Let us compile and run the above program, which will produce the following result:

The beginning of the program.... Exiting the program....

C Standard Library - <stdlib.h>

other extensions