Write a program for process creation using C.
(Use of GCC compiler).
Program =
#include
<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<unistd.h>
int main()
{
int pid;
pid=fork();
printf("Utsav Gohel - 91900104011\n");
if(pid<0)
{
printf("error occured");
exit(1);
}
else if(pid==0)
{
printf("\nChild process");
printf("\n My id is %d and My Parent id is
%d\n",getpid(),getppid());
exit(0);
}
else
{
printf("\n Parent process");
printf("\n My id is %d and My parent id is
%d\n",getpid(),getppid());
exit(1);
}
return 0;
}
Output =