PROCESS CREATION USING FORK,EXEC COMMANDS

SOURCE CODE:
#include<stdio.h>
int main()
{
int p;
printf(“ Origin Program, pid = %d\n ” , getpid());
p=fork();
if(p==0)
{
printf(“ In child process pid = %d , ppid= %d “, getpid(),getppid());
}
else
{
printf(“ In parent pid = %d, fork returned = %d \n”, getpid(),p);
}
}

OUTPUT:
[examuser35@localhost Jebastin]$ cc pro.c
[examuser35@localhost Jebastin]$ ./a.out
Origin Program, pid = 22386
In child process pid = 22837 , ppid= 22386
In parent pid = 22386 , fork returned = 22387
Previous
Next Post »

If you still didn't find what you're looking for, you can search this website below: