Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 2 Write a C program on Linux that creates children processes and does the following: Part I: - The parent process creates 1 child.
Problem 2
Write a C program on Linux that creates children processes and does the following:
Part I: - The parent process creates 1 child. - The child process itself creates 1 child. This will be the grandchild of the parent. - The parent process reads one number (integer) from the standard input. The parent process sends this number to the child using standard pipes. - The child multiplies the number by 2, prints it as "Child: Input X, Output X*2" and sends the result to the grandchild. - The grandchild multiplies the input number by 2, prints it as "Grandchild: Input X, Output X*2" and sends it back to the child. - The child will send the result back to the parent. - The parent prints the final result. - The parent kills all children processes, and terminates. Part II: Add a sleep(5) parameter to each process operation, so that you can track the behavior as it executes. Open two terminals. In the first terminal, run the tool *htop*. Once in htop, press *t* to sort all processes as a process tree. Resize the window so that you can see the processes properly. In the second terminal, execute your program. Find the program in htop, and take a screenshot of its hierarchy (parent/child/grandchild). Kill the child process amidst execution by pressing *k* in htop, and sending it SIGKILL to immediately terminate it. Take a screenshot of the program execution output. For Problem 2, you may need to use sleep(), kill() and fork() system calls. Refer to the ordinary pipe example in the textbookStep 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