For my own records
Sakura rental server Flask 1.1.1 Werkzeug 0.16.0
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
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.
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.
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.
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.
Easy to grasp the image of terms
Easy to understand as a summary
When and why you need a double fork
Recommended Posts