Question
The objective of this assignment is to use fork(), exec() and wait() calls to manage the creation and execution of a child process in C
The objective of this assignment is to use fork(), exec() and wait() calls to manage the creation and execution of a child process in C programs. The purpose of the program is to estimate the value for . For this program you will create two program files: program5.c and estimate.c. Each one is a complete program. The child program will execute the estimate. program5.c The code in program5 will use fork() to launch a child process, exec() in the child's logic to replace the image with the estimator program, and wait() to wait for the completion of the child process.
The program will take 2 command line arguments (the value for x and the number of terms to compute the estimate to).
The exec() will need to relay the command line arguments to the estimate program when it is invoked.
The parent process will print messages before and after the child process executes.
The final message should indicate the exit status of the child process. estimate.c The code in estimate will compute the actual estimate for and print it to the screen. Note that is given by the infinite series: = 1 + + 2 2! + 3 3! + If x< 1, the first few terms of the series provide an approximation of the actual value.
The child will print its PID before doing the computation.
The child will check for the following error conditions and will return an exit() code to indicate the problem to the parent. o Incorrect number of arguments. The estimate should get values for x and terms o Incorrect value of x. x must be in the range between (not including) 0.0 and 1.0 o Incorrect number of terms: the number of terms to compute the estimate to must be a positive integer.
Other Requirements:
Your program must be written in C, NOT using C++ statements.
Comment your program, and all variables, to indicate what it does
You must name your files program5.c and estimate.c. They must compile with the following commands, with no warnings. If you include other files in your solution, you must provide a working makefile AND zip your code up into a zip, tar or gz file before uploading to canvas. gcc -o prog5 program5.c gcc -o estimate estimate.c
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