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:
Program output for Fork( ) system call |
0 Comments