Tuesday, May 22, 2018

Program (using fork() and/or exec() commands)

/* Program (using fork() and/or exec() commands) where parent and child execute:
b. same program, different code
*/

#include<stdio.h>
#include<stdlib.h>
int main()
{
int a;
a=fork();
if(a<0)
{
 printf("Child process could not be created");
 exit(-1);
}
else if(a==0)
{
 printf("in child process=%d",getpid());
}
else
{
 printf("in parent process=%d\n",getppid());
}
return 0;
}




OUTPUT SCREEN:


No comments:

Post a Comment

Project on Library Management System (C++)

=> The project titled Library Management system is Library management software for monitoring and controlling the transactions in a lib...