Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The following C program utilises Unix operating system calls to run two processes simultaneously. Explain how the C program achieves this by explaining the purpose
The following C program utilises Unix operating system calls to run two processes simultaneously. Explain how the C program achieves this by explaining the purpose of each of the five highlighted operating system function calls. Assume the program child.exe is ready to be executed and returns a value of 5 using its exitfunction. #include #include #include #include int main() ForkPID, ChildPID; pi Unsigned int ChildStatus; Switch( ForkPID- fork)) Case 0: printf("fork() returned %d, my pid via getpid() is %dm", ForkPID, getpid( printf("About to execl)... fflush(stdout); execl("child", "child", "some arg", NULL); printf("Should never get here!!ln"); fflush(stdout); break case -1: perror("fork) failed:"; exit(1); default: printf("Process ID %d, other is %din", getpid(), ForkPD; fflush(stdout); ChildPID -wait(&ChildStatus); printf("other process PID %d gave exit status %din'. ChildPID, ChildStatus); fflush(stdout); exit(0)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started