DIR Return Create A Forum - Home
---------------------------------------------------------
Class Discussion
HTML https://srm.createaforum.com
---------------------------------------------------------
*****************************************************
DIR Return to: Operating System
*****************************************************
#Post#: 35--------------------------------------------------
Fork Process Creation - OS
DIR By: prannyll
Date: May 15, 2019, 12:04 am
---------------------------------------------------------
[move]FORK PROCESS CREATION[/move]
//Fork only works on Linus Terminal as Windows does not support
unistd.h header file
#include <stdio.h>
#include<unistd.h>
void main()
{
int n1 = fork();
if(n1 < 0)
{
printf("\nFork Failed!");
}
else if(n1 == 0)
{
execlp("/bin/ls","ls", NULL);
}
else
{
wait(NULL);
printf("Child Completed");
printf("\nID : %d", getpid());
printf("\nParent ID : %d", getppid());
}
}
*****************************************************
Page 1 of 1