nicolas-van / multirun

A minimalist init process designed for Docker
https://nicolas-van.github.io/multirun/
MIT License
182 stars 9 forks source link

Zombie processes #15

Closed pyrsmk closed 2 years ago

pyrsmk commented 2 years ago

Does it handle zombie processes correctly like Tini (or any other init manager) ?

Some info on the subject for those who may be interested : https://github.com/krallin/tini/issues/8#issuecomment-146135930

edit: typo

blackandred commented 2 years ago

If multirun detects that at least one process died, then exits all other processes. But I don't know if a zombie process means that process has exit > 0. Maybe its worth to check it and implement if its missing.

pyrsmk commented 2 years ago

Does multirun detects all exited processes or only the ones it's handling (from the multirun command) ? Because those zombie processes will mostly come from child processes.

nicolas-van commented 2 years ago

multirun only detects the state of the processes it creates. So no, it will never attempt to reap zombie processes that were launched by its original children. It's true that it would be an interesting feature to add, I'll look at it.

nicolas-van commented 2 years ago

I made some tests by creating a C program that voluntarily creates zombie processes before dying. I wasn't able to simulate a case were the zombie processes persisted despite the fact their parent died. This is probably due to multirun's behavior which is to wait for all children (regardless if they were original children or adopted ones) and just plainly ignore the ones it didn't spawned.

So in fact yes, it kind of does handle the zombie processes problem. Although it is not voluntarily but by chance.

Due to the fact I have some doubts regarding the fact that this behavior may be random and/or platform dependent and/or Linux version dependent (the man pages are quite difficult to understand) and also the fact that I completely understand people's concerns about zombies (I would be very sad to learn that I'm the cause of a zombie epidemy) I added some more checks inspired by tiny's source code and some other generic zombie handlers I could find in man pages.

So now we should be safe about zombies.

Unfortunately, after my tests, I figured that the is actually a more concerning problem: alive children.

If an original child spawns some children and then dies, multirun's behavior is to make sure all original children are killed but it does not take care of their descendants. That's a huge concern, as alive children are way more dangerous than zombies. Zombies are not very hard to kill, just shoot them in the head and you're done. Alive children are way smarter. They can hide from you and steal your food.

I'll be sure to improve multirun in order to make sure that whenever it decides to kill one of its children it does the job correctly and take care of all their descendant. I promise you, none of them will survive.

pyrsmk commented 2 years ago

I promise you, none of them will survive.

Yeah, kill them all! ☠️

pyrsmk commented 2 years ago

Anyway, thanks for your responsiveness. Multirun is the only init system that is really simple to use and that can handle several processes. So, thanks for the time you pass on it!

edit: typo

nicolas-van commented 2 years ago

Ok, version 1.1.0 released which should take care of all the potential problems I've seen. See the release note here: https://github.com/nicolas-van/multirun/releases/tag/1.1.0

pyrsmk commented 2 years ago

Wow, that was fast !

nicolas-van commented 2 years ago

It's the week end 😛 . Also I started a new job in C++ recently some a bit of C training is welcome.