Question
Write a function int run_program(char *file_path, char *argv[]) with the following features: Starts a program that may be specified by its full path and name
Write a function int run_program(char *file_path, char *argv[]) with the following features:
Starts a program that may be specified by its full path and name (i.e., /usr/bin/who) or only by its name if it is located in one of the directories contained in the PATH environment variable. Do not use system().
Passes the supplied arguments on to the new process.
Waits for the newly created process to exit.
Returns the special error value 127 to report an error condition and 0 to indicate success.
If file path is NULL, you should return the special error value. If argv is NULL, you should run the program without arguments. (Your program starter should not be terminated by an exception in either of the two cases.)
b. Modify the function to return the exit status of the previously started/exited process. Keep a return value of 127 to indicate error conditions in your own program.
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