Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions

Question

Where those not participating, encouraged to participate?

Answered: 1 week ago

Question

Were all members comfortable brainstorming in front of each other?

Answered: 1 week ago

Question

4. What will the team agreement contain?

Answered: 1 week ago