[PYTHON] [Unix] What is the zombie process / orphan process?

For my own records

environment

Sakura rental server Flask 1.1.1 Werkzeug 0.16.0

Thing you want to do

When there is a request from the client

--Parent process --Create a child process with fork --Return response to client --Disappeared without waiting for the child to end --Child process --Perform the processing passed from the client --Disappears after processing

Question

When a parent dies first, it's a zombie, an orphan, but it seems to get in the way? double fork? Do you have to do something like that? There was a description such as, so I actually looked it up.

result

What is a zombie process?

A child process that has finished processing and is waiting for the parent process to wait. When the child process is forked, the child process is added to the process table, and the child process is deleted from the process table with the wait of the parent process. In other words, a process that has finished processing but has not been taken over by the parent in wait.

What is the orphan process?

A child process that has terminated first and is no longer taken over by the parent's wait. A child process whose parent process has died first is re-parented to the init process, and the init process becomes the parent process thereafter. The init process actively waits and terminates the orphan process.

Summary

In other words, if the parent process is a resident process, children are created at various timings, and you do not know when to call wait, a large number of zombie processes will be created, which will put pressure on the system.

With the function I want to realize this time, the parent process will die quickly, so the child process will be properly taken over by init and will end, so do not do double fork.

Reference page

Easy to grasp the image of terms

Orphan Process Zombie Process

Easy to understand as a summary

Yahoo! Answers

When and why you need a double fork

HATENA Blog: Daemonizing processes with Double fork and implementing automatic server reload when changing files (Python)

Recommended Posts

[Unix] What is the zombie process / orphan process?
What is the difference between Unix and Linux?
What is the activation function?
What is the Linux kernel?
What is the interface for ...
What is the Callback function?
[Python] What is @? (About the decorator)
[python] What is the sorted key?
What is the X Window System?
What is the python underscore (_) for?
What is the ETL processing framework clivoa?
What is the cause of the following error?
Where is the python instantiation process written?
What is "mahjong" in the Python library? ??
I see, I will read the UNIX process
[Machine learning] What is the LP norm?
What is namespace
What is copy.copy ()
What is the difference between `pip` and` conda`?
What is Django? .. ..
What is POSIX?
What is Linux
What is klass?
What is SALOME?
What is Linux?
What is python
What is hyperopt?
It's a Mac. What is the Linux command Linux?
(Linux beginner) What is the magic word aux?
What is Linux
What is pyvenv
What is __call__
What is Linux
What is Python
What is the difference between usleep, nanosleep and clock_nanosleep?
What is the domain attribute written in Plotly's Layout?
Check if it is Unix in the scripting language
What is the true identity of Python's sort method "sort"? ??
What is a recommend engine? Summary of the types
Check if it is Unix in the scripting language
What is a distribution?
What is Piotroski's F-Score?
What is Raspberry Pi?
[Python] What is Pipeline ...
What is Calmar Ratio?
What is a terminal?
[PyTorch Tutorial ①] What is PyTorch?
What is hyperparameter tuning?
What is a hacker?
What is JSON? .. [Note]
What is Linux for?
What is a pointer?
What is ensemble learning?
What is TCP / IP?
What is Python's __init__.py?
What is an iterator?
What is UNIT-V Linux?
[Python] What is virtualenv
What is machine learning?
What is the default TLS version of the python requests module?
After deleting the Java process log, the log is no longer output