Question: 5. Read the code test.c below and answer questions. 1) Write the command to compile this code thus to generate an executable file named temp.

5. Read the code "test.c below and answer questions. 1) Write the command to compile this code thus to generate an executable file named temp. 2) Show the results of running this code and explain the reason behind. int main(void) { pid_t pid; int count=0; count = count + 1; pid=fork(); if(pid==0){ count = count +5; printf("part 1: count=%d ", count); execlp("/bin/ls", "IS", NULL); printf("part 1, pid is %d ", getpid(); } else if(pid>0){ count = count +7; printf("part 2: count=%d ",count); execlp("/bin/cp", "cp", "test.c", "myfile", NULL); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
