/* Program (using fork() and/or exec() commands) where parent and child execute:
c. different programs
*/
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
int main()
{
int a;
a=fork();
if(a<0)
{
printf("Child process could not be created");
exit(-1);
}
else if(a==0)
{
execl("/bin/ls","ls\n",NULL);
}
else
{
printf("\nParent process=%d\n",getppid());
}
return 0;
}
OUTPUT SCREEN:
c. different programs
*/
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
int main()
{
int a;
a=fork();
if(a<0)
{
printf("Child process could not be created");
exit(-1);
}
else if(a==0)
{
execl("/bin/ls","ls\n",NULL);
}
else
{
printf("\nParent process=%d\n",getppid());
}
return 0;
}
OUTPUT SCREEN:
No comments:
Post a Comment