Question: Write a program that takes a filename as a command - line argument and performs the following steps: 1 . Open the file specified as
Write a program that takes a filename as a commandline argument and performs the
following steps:
Open the file specified as the commandline argument.
Read contents of the file oneline at a time.
Use forkexec to create a new process that executes the program specified in the
input file along with the arguments provided.
The parent process will make note of the time the program was started you can
use a timer such as the time function defined in to capture the time before
the fork method is invoked, you can find out more about time function by
typing man time
Then the parent process will wait for the child process to complete and when the
child process terminates successfully, the parent process will capture the time the
child process completed you can again use a timer function to capture the time
when the wait function returns
Open a log file say output.log and write the command executed along with
arguments, start time of the process, and the end time of the process separated by
tabs Use ctime function to write the time in a human readable form.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
