Question: Write a multi-processed C program that does the following: The program takes two command line parameters. The first one is a program name; the second

Write a multi-processed C program that does the following:

The program takes two command line parameters.

The first one is a program name; the second one is a file name.

If the user enters a wrong number of parameters, display a usage message and exit.

The program creates a child process, using fork(), and runs the program in the child process, using exec().

You also need to figure out a way to redirect the standard output file of the child process to a file.

For example, if your program name is myprg1, then the following command line will run /bin/ps as a new process and redirect the output to myresult.txt: myprg1 /bin/ps myresult.txt

(hints: use dup() or similar system calls & redirect using stdin/stdout).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!