Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

when used as system init; need to reclaim zombie processes #26

Closed
c0b opened this issue Jul 6, 2017 · 8 comments · Fixed by #29
Closed

when used as system init; need to reclaim zombie processes #26

c0b opened this issue Jul 6, 2017 · 8 comments · Fixed by #29

Comments

@c0b
Copy link
Contributor

c0b commented Jul 6, 2017

linux kernel gives PID 1 with special responsibility to reclaim zombie process; otherwise zombies are accumulated more and more

# ps f -e | grep Z
[...]
   41 ?        Z      0:00 [cat] <defunct>
   42 ?        Z      0:00 [cat] <defunct>
@codeskyblue
Copy link
Owner

So, what is your problem?

@c0b
Copy link
Contributor Author

c0b commented Jul 7, 2017

when you're comparing gosuv with supervisor, did you consider all use cases of supervisor ? you may be aware that a common use case with supervisor is as init of multi services in container, it is a good and slim one if compare supervisor with the more traditional SysV-init or the new systemd style, it served well the purpose of multi-service_container; however because Supervisor/supervisor#122 such a high-demand feature can't be fixed for 5 years (since it was opened in 2012), one can reasonably guess that project is going out of maintenance; and I do see this project has potential to serve that purpose better

if you don't know the special responsibility when running as PID 1, you may refer to dumb-init (made by yelp engineering) or tini (integrated into docker 1.13+)

[1] https://docs.docker.com/engine/admin/multi-service_container/
[2] https://engineeringblog.yelp.com/2016/01/dumb-init-an-init-for-docker.html
[3] https://github.com/krallin/tini
[4] https://docs.docker.com/engine/reference/commandline/run/#options

Name, shorthand Default Description
--init false Run an init inside the container that forwards signals and reaps processes

@c0b
Copy link
Contributor Author

c0b commented Jul 10, 2017

some 3rd party programs might start with a launcher shell script, like this one, if you ever run google-chrome inside a container with gosuv as the init, you may observe this from outside of the container, from ps f -e notice the [cat] in zombie state, those were launched by chrome's launch script but they got somewhere abandoned, to regular linux system design, the init (either SysVinit or Systemd) will reap the zombies

12022 ?        Sl     0:00  |   \_ docker-containerd-shim daa830f18e20d.../var/run/docker/libcontainerd
12041 pts/0    Ssl+   0:00  |   |   \_ gosuv start-server -f
12118 ?        Ssl    0:22  |   |       \_ Xvfb :10 -screen 0 1920x1480x24+32 -ac -r -cc 4 -accessx -xinerama +extension Composite -extension RANDR +ext
12121 ?        Ssl    3:28  |   |       \_ /opt/google/chrome/chrome --no-first-run ...
[...]
12914 ?        Z      0:00  |   |       \_ [cat] <defunct>
12915 ?        Z      0:00  |   |       \_ [cat] <defunct>

@codeskyblue
Copy link
Owner

Understand

@codeskyblue
Copy link
Owner

@codeskyblue
Copy link
Owner

codeskyblue commented Jul 11, 2017

@c0b Can you test if it works.

@codeskyblue
Copy link
Owner

codeskyblue commented Jul 12, 2017

@c0b updated be857aa

@c0b
Copy link
Contributor Author

c0b commented Jul 14, 2017

with current master code I'm still seeing some zombies

c0b added a commit to c0b/gosuv that referenced this issue Jul 14, 2017
Current code isn't very correct: because Linux signal system design
follows SysV Unix behavior, when a SIGCHLD happens, it only means there
are child programs died (either self-quit or involuntarily killed, from
wstatus may figure out), linux kernel only deliver SIGCHLD once to parent
before the parent process;
so when SIGCHLD happens, you don't know is that one child only or more

so the code need a loop until wait4 returns zero, at rumtime got this:

```console
2017/07/14 21:14:32 reap dead child: 579, wstatus: 0x00000000
2017/07/14 21:14:32 reap dead child: 580, wstatus: 0x00000000
2017/07/14 21:14:32 reap dead child: 583, wstatus: 0x00000000
```

then in the container there are no more zombies. final resolve codeskyblue#26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants