/* Program (using fork() and/or exec() commands) where parent and child execute:
a. same program, same 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
{
printf("My process id=%d, My parent process id=%d\n",getpid(),getppid());
}
return 0;
}
a. same program, same 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
{
printf("My process id=%d, My parent process id=%d\n",getpid(),getppid());
}
return 0;
}
OUTPUT SCREEN:
No comments:
Post a Comment