Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Process Creation in Linux: Run the code below in the CLI and answer the questions that follow: #include #include #include unistd.h> int main(int argc,

image text in transcribed

1. Process Creation in Linux: Run the code below in the CLI and answer the questions that follow: #include #include #include unistd.h> int main(int argc, char *argv fork); fork(); sleep(10) printf("I am pocess Xd and return EXIT_SUCCESS my parent is %d ", getpid(), getppid()); endof function main */ a. How many processes are created (including the program itself)? b. Add a third fork () right after the ones in the program. How many processes are there? c. What is the relation between the number of consecutive fork calls and total number of processes created? Use shell commandpstree to capture the relations between the different processes of parts and b (hint: use the shell command ps to get your shell process pid; then use pstree -P) d. Inasan:parts$ ps -g PID TTY STAT TIME COMMAND 2 ttyl 1748 tty2 2030 tty2 R Inasan:parts& pstree 2 -p ash (2) part10 (22831) 0:00 /bin/bash 0:00 /bin/bash 0:00 ps -B Ss art10(22032)part10(22034) art18 (22033) Inasan:partss pstree 2-p ash (2)-part10(22044)-part10(22045)T-part10(22047)-part10(22951) art10 (22050) art10 (22046)part10(22049) part10(22048) Run the code after modifying it as follows: o Comment sleep (10) o Add two more fork) calls (a total of 5 times) Run the code multiple time. Why does the parent of some processes change (sometimes init process (PID 1) and sometimes the CLI)? Modify your code to make sure that a parent process will not terminate before any of its children e. f

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

OpenStack Trove

Authors: Amrith Kumar, Douglas Shelley

1st Edition

1484212215, 9781484212219

More Books

Students also viewed these Databases questions