Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Assignment 2: Linux System Calls - Process Management Write a C++ program that forks two child processes: 1- Child 1 process will look for all
Assignment 2: Linux System Calls - Process Management Write a C++ program that forks two child processes: 1- Child 1 process will look for all the C++ programs stored in your home directory and store the searching results in a text file called (CPP_files.txt). (ONE statement ONLY to accomplish this task) Hint: you need to use (find *.cpp) command, the result of the find command should be stored in the CPP_files.txt file. 2- Child 2 process should reads the content of (CPP_files.txt) file and it should find number of lines in each .cpp file and store the results in a file called Output.txt Hint: you need to use the (wc-1) command. Child 2 MUST use the execve system call to accomplish its task. 3- At the end, the parent Process should delete the CPP_files.txt file. CPP_files.txt prog1.cpp test.cpp prog2.cpp Assignment_1.cpp Output.txt 15 progi.cpp 48 test.cpp 12 prog2.cpp 60 Assignment_1.cpp A Sample program that reads from file in C++: #include #include // include the fstream (file stream library) using namespace std; int main() { // declaring an input file called infile ifstream infile; // opening the input file (file we will read from) that called CPP_files.txt infile.open("CPP_files.txt"); string str; // loop to read the content of the file line by line till the end of the file while(infile>>str) { // display the line we read from the file on the screen (terminal) cout
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