Answered step by step
Verified Expert Solution
Link Copied!

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 (lastnameTestInheritance1,2.c):
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 n=5.
Fork the program.
Print n.
Wait for the child process.
Print n.
Child process:
Sleep for 5 seconds.
Print n.
Increase n by one.
Print n.
Start each print in the parent process with "p". 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?
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions