Dead or zombie Process in Linux

In the Linux operating system, you will sometimes come across programs called dead processes or Zombie  process, these types of programs have become like this due to weaknesses or poorly written structural code. Today, in this article, we will discuss how these types of programs are created and how to remove them from our computers.

Processing steps in Linux

In the Linux OS, the program will be automatically monitored by the operating system, so that any program or Daemon that you are running is monitored and located inside the processing desk. That part of the program structure is stored in the memory kernel, and the system can save them by numbering, also in this list all input values ​​store some information from the processes.

But there is not much information inside the numbers in the storage processing table, the information inside these numbers includes the IDs of the processes, several dates and times of the processes, and finally the PCB related to those processes.

At the moment of processing, all tasks are the responsibility of PCBs. At the time of each processing, they are updated and when the processes are destroyed, they are destroyed with them, so PCBs carry very important information from different processes.

Linux PCBs have more than 700 commands and there is a lot of information in them, one of their structures is task_struct.h.

We have collected all the contents that you encounter in PCB :

  • Process State: The status of the processes is specified for the user in this section.
  • Process Number: This is to identify and differentiate each process from the other by the operating system.
  • Program Counter: This command will create an order list for your processes, and in this section, it will be specified that after closing the process, a new process will start.
  • Registers: In this list, you will see the processors registered by this process, also this list may include accumulators, index registers, and stack pointers.
  • Open File List: Files associated with this process.
  • CPU Scheduling Information: This option determines how much CPU and for how long the processor has, as well as the CPU priority, and all information about your CPU will be recorded on the PCB.
  • Memory Management Information: This will give you information and descriptions of the memory that this process uses, for example, the full start and end of each process, as well as the poets of the memory screens.
  • I / O Status Information: Any input or output device that has used the processing.

One of the things to we have to pay extra attention to is the Process State, which can be one of the following:

  • R: This letter indicates a process is running or ready to run, if the process is running it means it is running and using CPU resources, if it is ready to run it means This process is in the activation queue and will start as soon as the processor is empty.

    S: This letter indicates a process that is in standby mode, for example, this process needs this particular output or input to complete, or it is ready to use resources in standby mode.

    D: This indicates that the processing is absolute in standby mode, unlike the standby mode this state can not be affected by the user or continued, the processing needs all the necessary items to run.

    T: This indicates that the processing has stopped completely because it has received the SIGSTOP signal, in which case the processing will only respond to the SIGKILL and SIGCONT signals, which may, respectively, cause the process to destroy or continue processing.

    Z: A dead process. When a process is completed, it will be free by itself,it will free up the amount of memory it has, but these events still remain on the process desk and PCB and can be seen.

When the process is dead, the older processes, known as the Parent process, use another feature and create a new process, then wait for a change in the new process. It comes, waits, and monitors the new process to see if the new process has stopped, run, or been deleted by one of the signals.

If the new processing conditions change in a way that means it is gone, its exit code is Read. The newly created PCB will then be destroyed and its values ​​will be cleared from the processing table, ideally, It will happen in a moment, and dead processing will not be on the processing table for long.

What is the cause of Zombie Process

In most cases, this type of processing is due to poor programming, for example, when older processes run the wait () command for the newly created process, the SIGCHLD command, which is used to announce changes in New processing is ignored.

In some cases, another program may interfere with the SIGCHLD code, this may be due to malware or code programming weakness. In any case, when there is no monitoring of newly created processes, processing Do not announce their changes, and this will not remove dead processes, so these processes will never be removed from the PCB.

Dead processes use very little memory, and usually do not pose any problems for normal use of the operating system. Using these processes does not take up much space on the processing desk, but the problem will arise where the processing is dead. It will not be removed from the processing desk, making it impossible for any other process to run. However, on a 64-bit operating system, this will not be a problem, as the PCB will be larger than the process table.

Many dead processes can simultaneously occupy the free RAM space available for other processes. If there are many dead processes in your system, there may be a problem with your older processes or with the operating system.

Destroy Zombie Process

Enter the following commands in order, on your process table:

top

Now in the Task section, you can see all your processes in order.

We can list them using the ps command and shape them into columns using egrep.

As we said, dead processes will be shown with the letter z, and we will also add the defunct command. Enter the following command:

ps aux | egrep "Z|defunct"

Dead processes are displayed as a list. Also in the last column of dead processes information, you can see what program or process caused them.

To remove the dead processes we have to proceed through the process they created, enter the following command:

ps -o ppid= -p 0000

In the red field, you have to enter your desired PID.

At the bottom, the terminal will show you the main process that caused the dead process.

Now let’s use the PS command again to see the main process:

ps -e | grep 0000

This time in the red section we will put the main processing number that the terminal gave a little earlier.

We will use the SIGKILL command to delete mother processes:

kill -SIGKILL 0000

 

26 Comments

  • Everything is very open with a really clear description of the issues. Magda Filmore Vaclava

  • Thank you ever so for you blog post. Really looking forward to read more. Cool. Dorelle Westbrooke Fogg

  • Nice blog post. I learn something a lot more difficult on different blog sites everyday. It will certainly constantly be promoting to review content from other authors as well as exercise a something from their shop. I?d prefer to utilize some with the material on my blog whether you don?t mind. Natually I?ll give you a link on your web blog. Many thanks for sharing. Lane Skye Roybn

  • This website has lots of really useful stuff on it. Thanks for informing me. Daffi Sanford Hume

  • I view something really interesting about your weblog so I saved to my bookmarks . Mady Caspar Marius

  • Very heartfelt and provocative, Di. You are an inspiration. This really changed my mindset about the unnecessary acquisition of worldly things. Thank you for sharing your many gifts with so many people in this world! Kay Shalom Balthazar

  • I have been absent for a while, but now I remember why I used to love this web site. Thank you, I will try and check back more often. How frequently you update your site? Madelina Thornie Petronella

  • I am truly glad to glance at this weblog posts which containsplenty of helpful facts, thanks for providing such information. Trixy Jesse Ingham

  • I was excited to uncover this site. I wanted to thank you for ones time due to this wonderful read!! Lizette Sonny Goldenberg

  • At this time it seems like BlogEngine is the top blogging platform available right now. Janetta Ethelbert Agace Nolana Don Gualtiero

  • It’s the best time to make some plans for the future and it’s time to be happy. I’ve read this post and if I could I desire to suggest you few interesting things or advice. Perhaps you can write next articles referring to this article. I wish to read even more things about it! Lisbeth Sander Bendix

  • You have made some decent points there. I checked on the web for additional information about the issue and found most people will go along with your views on this website. Cordelia Ikey Wind

  • There is certainly a great deal to know about this issue. I love all of the points you made. Consolata Bond Frederiksen

  • Caid and her taste-testing. Thankful that you choose to put aside your self-centeredness to love, connect and make room for us! Tish Christoper Hyps

  • You have made some good points there. I checked on the net for more info about the issue and found most individuals will go along with your views on this website. Carlin Rufe Sedgewick

  • I am glad to be a visitant of this double dyed weblog, regards for this rare info! Gui Giacopo Thackeray

  • As a Newbie, I am constantly browsing online for articles that can benefit me. Thank you Margot Sid Adamo

  • Hey there. I discovered your site via Google even as looking for a related matter, your web site got here up. It seems to be great. I have bookmarked it in my google bookmarks to come back then. Gerry Hadrian Kenwee

  • Just desire to say your article is as astounding. The clearness in your post is just cool and i can assume you are an expert on this subject. Fine with your permission let me to grab your feed to keep up to date with forthcoming post. Thanks a million and please continue the gratifying work. Nertie Brendon Stieglitz

  • But wanna comment on few general things, The website style and design is perfect, the written content is real great : D. Abigail Ollie Vally

  • Great collection of images website. This will help us to use copyright free commercial images. Thanks for sharing valuable information. Kacey Holly Beckman

  • A very informationrmative story and lots of really honest and forthright comments made! This certainly got me thinking about this issue, cheers all. Nara Stanleigh Gilbye

  • So happy you are satisfied with our company. We appreciate your business and your comments. Muffin Michele Gentilis Kendra Jethro Ned

  • I really like and appreciate your blog. Thanks Again. Rubi Granny Nedi Brooks Duff Ivonne

  • Awesome write-up. I am a normal visitor of your web site and appreciate you taking the time to maintain the excellent site. I will be a regular visitor for a long time. Dorothee Padraig Izy

  • Interesting blog! Is your theme custom made or did you download it from somewhere? A design like yours with a few simple tweeks would really make my blog jump out. Please let me know where you got your design. Bless you Adiana Nathanial Baily

Leave a Reply

Your email address will not be published. Required fields are marked *