Question: Fork using exec function to compile and run another program. So what i am trying to do is, i want to compile and execute Program1.c

Fork using exec function to compile and run another program.

So what i am trying to do is, i want to compile and execute Program1.c file from the child process of Program2.c

This is Program2.c

#include #include

int main () { printf ("just one process only "); printf("calling fork "); int pid = fork(); if (pid==0) { printf("I am child process.");

execl("/usr/bin/gcc", "gcc","/home/folder/Program1.c", "-o", "/home/folder/Program1", NULL); } else if (pid > 0) { printf("I am parent process. "); } else { printf("Error in fork"); } return 0; }

This is Program1.c

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!