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.
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