Synopsis In this assignment, you will have a parent process that will create children processes to perform tasks and will collect the output from these children processes. There are three tasks that should be performed: • Read the input file that contains Linux shell commands. Parent process will read that. • Execute the Linux shell commands read from the input file and execute them one by one. A child process will be created to execute these commands and the output will be returned by the child process in the form of string using pipe. • The parent process will write the output of commands to the screen. • The following flow chart describes the flow of the program. Description Write a C program that includes the code for following tasks. Write all the code in single file: 1. Write the parent program as per the description in the “Synopsis”. The parent program must use fork system call to create children processes when required. 2. Read the sample input file, sample_in.txt. The name of the file must be given to the main/parent process through command line arguments. a) This file contains one shell command per line. b) Since the file is created in a Windows environment, the line terminator is ‘\r\n’. 3. Store the commands in a dynamically allocated array. sample_in.txt: pwd ls -l -a -F ps pwd -L -P ls cat makefile P.S. Plese explain what each line is doing in comment please
Synopsis
In this assignment, you will have a parent process that will create children processes to perform tasks and
will collect the output from these children processes. There are three tasks that should be performed:
• Read the input file that contains Linux shell commands. Parent process will read that.
• Execute the Linux shell commands read from the input file and execute them one by one. A child process will be created to execute these commands and the output will be returned by the child process in the form of string using pipe.
• The parent process will write the output of commands to the screen.
• The following flow chart describes the flow of the
Description
Write a C program that includes the code for following tasks. Write all the code in single file:
1. Write the parent program as per the description in the “Synopsis”. The parent program must use fork system call to create children processes when required.
2. Read the sample input file, sample_in.txt. The name of the file must be given to the main/parent process through command line arguments.
a) This file contains one shell command per line.
b) Since the file is created in a Windows environment, the line terminator is ‘\r\n’.
3. Store the commands in a dynamically allocated array.
sample_in.txt:
pwd
ls -l -a -F
ps
pwd -L -P
ls
cat makefile
P.S. Plese explain what each line is doing in comment please
Trending now
This is a popular solution!
Step by step
Solved in 2 steps