How to use exit() System call

C program to show how to use exit system call. The function exit() is used to exit from a process (or to terminate a process). This works both in Linux or UNIX and Windows operating systems.

#include<stdio.h>
main()
{

int pid;
pid=fork();
printf("%d\n",pid);
if(pid<0)
{
perror("Child can't be executed\n");
exit(-1);
}
else
{
printf("Child created\n");
exit(0);
}
}

No comments :

Post a Comment