- Что такое процесс и почему его не убивают?
- ps -ef | grep defunct
- Defunct process
- How to get rid of them [ edit ]
- The long story [ edit ]
- Зомби процессы Linux
- How to Kill Zombie Processes in Ubuntu 18.04 LTS
- Viewing Zombie Processes
- Through the GUI
- Through the Command Line
- Killing a Zombie-Process
- Through the GUI
- Through the Command Line
- Karim Buzdar
- Killing a defunct process on UNIX system [closed]
- 5 Answers 5
Что такое процесс и почему его не убивают?
Браузер Chrome не реагировал, и я попытался убить его, но вместо того, чтобы исчезнуть, процесс имел право и не был убит:
Что за процесс и почему его не убить?
Из вашего вывода мы видим «несуществующий», что означает, что процесс либо завершил свою задачу, либо был поврежден или уничтожен, но его дочерние процессы все еще работают или эти родительские процессы отслеживают свой дочерний процесс. Чтобы убить такой процесс, kill -9 PID не работает. Вы можете попытаться убить их с помощью этой команды, но она будет показывать это снова и снова.
Определите, кто является родительским процессом этого несуществующего процесса, и уничтожьте его. Чтобы узнать это, запустите команду:
ps -ef | grep defunct
Затем kill -9 637 27872 , затем убедитесь, что несуществующий процесс прошел ps -ef | grep defunct .
Отмеченные процессы — это мертвые процессы (так называемые «зомби» ), которые остаются, потому что их родитель не уничтожил их должным образом. Эти процессы будут уничтожены, init(8) если родительский процесс завершится.
Вы не можете убить его, потому что он уже мертв. Остается только запись в таблице процессов :
В Unix и Unix-подобных компьютерных операционных системах процесс зомби или несуществующий процесс — это процесс, который завершил выполнение, но все еще имеет запись в таблице процессов. Эта запись все еще необходима для того, чтобы родительский процесс мог прочитать статус выхода своего дочернего процесса.
Нет ничего плохого в том, чтобы позволить таким процессам быть, если их не много. Зомби в конце концов пожинает его родитель (по вызову wait(2) ). Если исходный родитель не получил его до своего выхода, init process ( pid == 1 ) сделает это позже. Зомби Процесс это просто:
Процесс, который завершился и который удален, когда его состояние завершения было сообщено другому процессу, который ожидает завершения этого процесса.
Спасибо, Майк С. Мы взяли вашу строку и написали скрипт, который уничтожит несуществующие процессы, чьим родителем является in.telnetd. Мы не хотели, чтобы он уничтожал какой-либо родительский процесс, просто мы знаем, что telnetd вызывает проблему, и мы будем запускать его несколько раз, чтобы убить несколько, если это необходимо.
развивая ответ Паддингтона ..
Из вашего вывода мы видим несуществующий , что означает, что этот дочерний процесс либо выполнил свою задачу, либо был поврежден или уничтожен. Его родительский процесс все еще выполняется и не заметил своего мертвого потомка.
kill -9 PID не будет работать (уже мертв).
Чтобы определить родителя этого дочернего процесса, выполните следующую команду:
ps -ef | grep defunct
Посмотрите, кто является родителем: ps ax | grep 27872
Если вы хотите, вы можете убить родителя, и несуществующий исчезнет. kill -9 27872
см. ответ Дж.Ф. Себастьяна для более технических рассуждений.
Источник
Defunct process
A «defunct» process (sometimes referred to as «zombie») is a process that is actually finished which depends on a parent process which for some reason (=error) has not accepted the knowledge that it is finished and should be terminated.
How to get rid of them [ edit ]
Defunct processes will sometimes show up in the process list (top and ps -aux). Many people, including myself, find these annoying. Additionally, the reason for processes to be listed as defunct is that something has gone wrong with the parent process.
The solution is to find out what parent process the defunct processes belong to and stop it (or restart it).
The long story [ edit ]
Unix manages an explicit parent-child relationships between processes (Windows does not do this).
When a child process dies, the parent process recieves a notification. It is then the duty of the parent process to explicitly take notice of the childs demise by using the wait() system call.
The return value of the wait() is the process ID of the child, which gives the parent exact control about which of its children are still alive. Upon returning, wait() will have set the integer pointed to by its argument to the exit status of the child. A shell programm like «bash» could then decide how to process following commands and set the special $? variable accordingly.
As long as the parent hasn’t called wait(), the system needs to keep the dead child in the global process list, because that’s the only place where the process ID is stored. The purpose of the «zombies» is really just for the system to remember the process ID, so that it can inform the parent process about it on request.
If the parent «forgets» to collect on its children, then the zombie will stay undead forever.
Well, almost forever. If the parent itself dies, then «init» (the system process with the ID 0) will take over fostership over its children and catch up on the neglected parental duties. This is why you need to identify the parent process and stop or restart it in order to get rid of defunct processes. If the zombie process has id nnnnn, you can do ps -ef | grep nnnnn and find the id of the parent process, which you can then kill if no longer needed. Then the defunct process will be removed from the list.
Источник
Зомби процессы Linux
Каждая программа, которая выполняется в Linux, — это системный процесс, у которого есть свой идентификатор. Каждый процесс может запускать дочерние процессы с помощью функции fork. Такие процессы остаются под контролем родительского процесса и не могут быть завершены без его ведома. Если один из дочерних процессов всё же завершился, а его родительский процесс не смог получить об этом информацию, то такой дочерний процесс становится зомби.
Зомби процессы Linux не выполняются и убить их нельзя, даже с помощью sigkill, они продолжают висеть в памяти, пока не будет завершён их родительский процесс.
Посмотреть такие процессы можно с помощью утилиты ps, здесь они отмечаются как defunct:
ps aux | grep defunct
Если вы попытаетесь убить такой процесс с помощью сигнала KILL, то ничего не выйдет:
Чтобы его завершить, нужно найти «родителя» этого процесса. Для этого используйте команду:
ps -xal | grep defunct
Здесь идентификатор родительского процесса находится в четвёртой колонке (PPID). Теперь мы можем послать ему сигнал завершения, и такого процесса в системе больше не будет:
Для большего удобства вы можете использовать утилиты top или htop, но принцип их действия будет аналогичным, поэтому я не буду здесь его рассматривать. Теперь вы знаете, что делать, если в вашей системе появились зомби процессы Linux.
Источник
How to Kill Zombie Processes in Ubuntu 18.04 LTS
A zombie or a defunct process in Linux is a process that has been completed, but its entry still remains in the process table due to lack of correspondence between the parent and child processes. Usually, a parent process keeps a check on the status of its child processes through the wait() function. When the child process has finished, the wait function signals the parent to completely exit the process from the memory. However, if the parent fails to call the wait function for any of its children, the child process remains alive in the system as a dead or zombie process. These zombie processes might accumulate, in large numbers, on your system and affect its performance. In that case, you might have to kill these zombies manually through the ways and commands described in this tutorial.
Viewing Zombie Processes
You can have a check on your system performance by viewing the various processes running on your system, including the efficiency altering zombie processes. Ubuntu allows you to view these processes in the following manner:
- Through the Graphical User Interface
- Through the Command Line
Through the GUI
In order to graphically view any zombie processes running on your system, open the System Monitor utility through your Ubuntu Dash. In the following screenshot of my System Monitor, you can view that there are two zombies running on my system. It is also possible that the number of zombie processes on your system might be less or more than the ones running on mine.
Through the Command Line
The top command displays a detailed view of the processes running on your system along with the memory and CPU resources they are using. It also gives you information about any zombie processes running on your system. Open the Terminal by pressing Ctrl+Alt+T and then type top. I got the following output after running this command.
You can see in the second line that there is 1 zombie process running on my system.
If you want further details about the zombie process, use the following command:
This command will give you the state, parentID, the process ID, the program that is running the zombie process(a dummy program by the name ‘zombie’ on my system). The defunct flag tells you that this is a dead, zombie process.
Killing a Zombie-Process
First, let us understand how zombie processes are a threat to our system’s performance. It is important to learn that zombies are dead and mostly completed processes that do not take memory or CPU resources. However, each of these processes has a unique process ID assigned to them which comes from a limited pool of PIDs reserved for your processor. If a large number of zombies gather, they will eat up most part of the PID pool and the new processes will not be able to launch due to lack of a process ID. Advertisement
A small number of defunct programs occupying your system is not a big threat but that means that their parent programs have not been able to call them off due to a bug or a missing wait() function.
When a parent process has not been able to call the wait() function automatically, we need to manually signal the parent process to run the wait function on all its children so the ones with a complete state can be called back. We can do this by running the SIGCHLD command. When that doesn’t work, we can manually kill the parent process so that all its zombie children are also killed, freeing the process IDs for the new processes.
You can kill the zombie processes through the following ways:
- Through the Graphical User Interface
- Through the Command Line
Through the GUI
You can kill a zombie process graphically through the System Monitor Utility as follows:
- Open the System Monitor utility through Ubuntu Dash.
- Search for the term Zombie through the Search button.
- Select the zombie process, right-click and then select Kill from the menu.
The zombie process will be killed from your system.
Through the Command Line
After you know that there any zombie processes running on your system through the top command, view the details of the processes.
The usual way is to use the following command that signals the zombie’s parent process to kill the command.
This command may not work in a few cases as not all parent processes are programmed properly in order check upon the child processes. In that case, you can kill the parent process through the following command:
When you have killed all the zombie processes through this way and run the top command, you will be able to see that there are no zombie processes running on your system anymore:
After working along with this tutorial, you can optimize your operating system by looking for any zombie processes on your system and killing them manually through the command line or the graphical user interface. This act will free up process IDs for the new processes that you want to run on your system.
Karim Buzdar
About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn
Источник
Killing a defunct process on UNIX system [closed]
Want to improve this question? Update the question so it’s on-topic for Stack Overflow.
Closed 8 years ago .
I have a defunct process on my system:
How can I kill the above process, without a reboot of the machine? I have tried with
5 Answers 5
You have killed the process, but a dead process doesn’t disappear from the process table until its parent process performs a task called «reaping» (essentially calling wait(3) for that process to read its exit status). Dead processes that haven’t been reaped are called «zombie processes.»
The parent process id you see for 31756 is process id 1, which always belongs to init . That process should reap its zombie processes periodically, but if it can’t, they will remain zombies in the process table until you reboot.
Did you check for a child process that may need to be killed first? Sometimes the jam up is down the line. Try ps -ef —forest
to see what may be below it (if anything) then kill that first, then the one you already know about
If kill -9 fails to kill a process the cause is almost always a driver or operating system bug.
The init process has adopted the process, but it cannot reap it. That is to say: when init calls wait(2) that process is not returned. One of the primary purposes of init is to reap dead orphaned children, so the problem is not that its parent died before it was reaped. Think: Otherwise, who reaps the results of a nohup’d process after logout?
Killing children of the defunct process is unlikely to help unless they are somehow related to the particular bug you are seeing.
Источник