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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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

Read from file and write to dynamic array
fork()
Child Process
Run
5
Parent
command
Process
Write to pipe
Read from pipe
Write to screen using given
function, one by one
pipe
Performed multiple times
Transcribed Image Text:Read from file and write to dynamic array fork() Child Process Run 5 Parent command Process Write to pipe Read from pipe Write to screen using given function, one by one pipe Performed multiple times
File
sample_in - Notepad
Edit
pwd
ls -1 -a -F
ps
pwd - L -P
1s
cat makefile
View
Transcribed Image Text:File sample_in - Notepad Edit pwd ls -1 -a -F ps pwd - L -P 1s cat makefile View
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education