From eea0fbfec1274aee493cd113327619648fb71406 Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Tue, 28 Apr 2020 22:53:59 +1000 Subject: [PATCH] docs: terminals: mention subreaper requirement I realised that the terminal documentation which covers detached terminals fails to mention that callers need to make themselves a subreaper. Probably a good idea to mention this. I've also included a minor comparison to LXC. Signed-off-by: Aleksa Sarai --- docs/terminals.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/terminals.md b/docs/terminals.md index fc000e1a..649675c9 100644 --- a/docs/terminals.md +++ b/docs/terminals.md @@ -228,6 +228,19 @@ Unfortunately using detached mode is a bit more complicated and requires more care than the foreground mode -- mainly because it is now up to the caller to handle the `stdio` of the container. +Another complication is that the parent process is responsible for acting as +the subreaper for the container. In short, you need to call +`prctl(PR_SET_CHILD_SUBREAPER, 1, ...)` in the parent process and correctly +handle the implications of being a subreaper. Failing to do so may result in +zombie processes being accumulated on your host. + +These tasks are usually performed by a dedicated (and minimal) monitor process +per-container. For the sake of comparison, other runtimes such as LXC do not +have an equivalent detached mode and instead integrate this monitor process +into the container runtime itself -- this has several tradeoffs, and runc has +opted to support delegating the monitoring responsibility to the parent process +through this detached mode. + #### Detached Pass-Through #### In detached mode, pass-through actually does what it says on the tin -- the