Implement the C Program to create a child process using fork(), display parent and child process id. Child process will display the message “I am Child Process” and the parent process should display “I am Parent Process”.
#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>
void ChildProcess();
void ParentProcess();
int main()
{
pid_t pid;
pid=fork();
if (pid==0)
ChildProcess();
else
ParentProcess();
return 0;
}
void ChildProcess()
{
printf("I am child process..");
}
void ParentProcess()
{
printf("I am parent process..");
}
Comments
Post a Comment