Sie sind auf Seite 1von 1

Lab No : 04

To Create a Child Process by using Fork ( ) in Linux


Code:
#include<stdio.h>
main()
{
int val,pid;
printf("Another Program\n");
val=fork();
if (val==0)
{
printf("%d",getpid());
printf("Child Process\n");
}
else
{
printf("Child Process has id : %d,val);
printf("Parent Process \n");
pid=getpid();
printf("Process id : %d \n",pid);
}
}

Output:

Das könnte Ihnen auch gefallen