Answered step by step
Verified Expert Solution
Question
1 Approved Answer
What gets inherited by child processes ( lastnameTestInheritance 1 , 2 . c ) : In Linux, a newly created process inherits many attributes from
What gets inherited by child processes lastnameTestInheritancec:
In Linux, a newly created process inherits many attributes from its parent, including the parent's
variables and its open file descriptors. Follow the steps below to test what attributes are
inherited by a child process:
Test inheritance of variables:
Parent process:
Define a variable
Fork the program.
Print
Wait for the child process.
Print
Child process:
Sleep for seconds.
Print
Increase by one.
Print
Start each print in the parent process with Start each print in the child process
with c
a In what order do the four prints occur? For example, "child then parent then parent
then..." Why?
b What values are printed by the parent? Why? What values are printed by the child?
Why?
Test inheritance of open file descriptors:
Parent process:
Child process:
Open a file to write.
Fork the program.
Write "parent" to the file.
Close the file.
Write "child" to the file.
Close the file.
c Do both processes write to the file? Why or why not?
d Run the program multiple times. Which processes print? in what order? and why?
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