1. execute the program in the background 2. obtain process status 3. show to the zombie child process details 4. show the shell 5. show the parent process details 6. kill the parent process 7. notice the zombie is gone

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Please answer the question in the code using ubunto 

the code : 

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/wait.h>
int main ( ) {
int pid ;
pid = fork(); /* Duplicate. Child and parent continue from
here */
/* pid is non-zero, so I must be the parent */
/* Never terminate and never execute a wait ( )
*/ /* stop executing for 100 seconds */
if ( pid != 0 )
{
while (1)
sleep (100) ;
}
else /* pid is zero, so I must be the child */
{
exit (42) ; /* exit with any number */
}
}

 
Exercises
Note: Do the following task using ubuntu.
Example Lab7.c
1. execute the program in the background
2. obtain process status
3. show to the zombie child process details
4. show the shell
5. show the parent process details
6. kill the parent process
7. notice the zombie is gone
Transcribed Image Text:Exercises Note: Do the following task using ubuntu. Example Lab7.c 1. execute the program in the background 2. obtain process status 3. show to the zombie child process details 4. show the shell 5. show the parent process details 6. kill the parent process 7. notice the zombie is gone
Zombie processes
A process that terminates cannot leave the system until its parent accepts its return code. If its parent
process is already dead, it’ll already have been adopted by the “init" process, which always accepts
its children's return codes. However, if a process's parent is alive but never executes a wait ( ), the
process's return code will never be accepted and the process will remain a zombie.
The following program created a zombie process, which was indicated in the output from the ps
utility. When the parent process is killed, the child was adopted by “init" and allowed to rest in
реаce.
Еxample
Lab7.c:
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/wait.h>
int main ( ) {
int
pid ;
= fork ();/* Duplicate. Child and parent continue from
pid
here */
/* pid is non-zero, so I must be the parent */
/* Never terminate and never execute a wait ()
*/ /* stop executing for 100 seconds */
if ( pid != 0 )
{
while (1)
sleep (100) ;
}
else
/* pid is zero,
so I must be the child */
{
exit (42) ;
/* exit with any number */
}
}
Transcribed Image Text:Zombie processes A process that terminates cannot leave the system until its parent accepts its return code. If its parent process is already dead, it’ll already have been adopted by the “init" process, which always accepts its children's return codes. However, if a process's parent is alive but never executes a wait ( ), the process's return code will never be accepted and the process will remain a zombie. The following program created a zombie process, which was indicated in the output from the ps utility. When the parent process is killed, the child was adopted by “init" and allowed to rest in реаce. Еxample Lab7.c: #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/wait.h> int main ( ) { int pid ; = fork ();/* Duplicate. Child and parent continue from pid here */ /* pid is non-zero, so I must be the parent */ /* Never terminate and never execute a wait () */ /* stop executing for 100 seconds */ if ( pid != 0 ) { while (1) sleep (100) ; } else /* pid is zero, so I must be the child */ { exit (42) ; /* exit with any number */ } }
Expert Solution
steps

Step by step

Solved in 3 steps with 6 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY