Header Ads Widget

Responsive Advertisement

Latest

6/recent/ticker-posts

Illustration of Fork ( ) System call

Fork( ) System Call and process creation ( example )

 

Predict the output

 
#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>
void forkcall( )
{
  int x=2;
  if(fork()==0)
      printf("child has x=%d\n",++x);
 else
      printf("parent has x=%d\n",--x);
}
int main()
{
   forkcall( );
    return 0;
}


OUTPUT:

Output of Fork( ) Sytem call
Program output for Fork( ) system call

Post a Comment

0 Comments