Question: (2) Write a Unix program that does the following You run the program in command line using the following syntax: you_program_name file_name Where file_name is
(2) Write a Unix program that does the following
You run the program in command line using the following syntax:
you_program_name file_name
Where file_name is the name of a text file under the current directory
When the program starts, it does the following
If filename is not specified in the command line, or if there are too many parameters, display the correct usage and then exit. Otherwise,
It forks three (3) child processes
The parent process then displays its own PID information only once, then waits for all its child processes die (hint: use wait() for this.. The wait() system call suspends the calling process until one of its child processes dies.)
Let one child-process run the "ls -l" command (using the "execl" system call); Let another child-process run the "ps -ef" command; Let the third child-process display the content of the file (specified by file_name). You can use the program "more" or "cat" to display it. After all child processes terminate, the main process displays "main process terminates" then exits. This should be the last piece of information displayed by your program.
I am aware that this question has been posted before but running the solutions in gitbash/ubuntu are not working and I am receiving "unexpected token" syntax errors, quite frankly I am not sure how Unix scripts work and should be ran. My professor isn't very helpful in explaining so any additional assistance would be greatly appreciated.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
