Re: register runsvdir as subreaper

From: Steve Litt <>
Date: Wed, 1 Feb 2017 12:49:42 -0500

On Mon, 30 Jan 2017 09:38:38 -0800
Mitar <> wrote:

> Hi!
> I would like to ask if runsvdir could by default be defined as a
> subreaper on Linux. If it is already a PID 1, then there is no
> difference, but sometimes it is not. In that case when an orphan
> process happens under it, then it would be re-parented under the
> runsvdir, mimicking the behavior when runsvdir runs as a PID 1.
> runit is often used in Docker containers and sometimes you have a
> wrapper script which spawns runsvdir as a child. In that case runsvdir
> does not run as PID 1.

Hi Mitar,

As far as I know, runsvdir from the runit project is never PID1: It's
called from an sv that's forked by PID1. On my computer, the program
called runit is PID1, and its child is runsvdir. The runit program
reaps zombies.

You might want to do a ps axjf | less on your Docker to see what's
really acting as PID1, and see if you can reap zombies there.

Check out the PID1 code at the bottom of .
Note the following code:

for (;;) wait(&status);

The preceding reaps zombies. Perhaps you could start up runsvdir with
that. But wait,there's more. The folks at Suckless Tools wrote a better
version of the code that also handles signals:

If you have control over the Docker container, and if you're initting
via runit, you almost certainly have a distinct PID1 that does little
but reap zombies, listen for signals, and fork the sv system which of
course spawns runsvdir.

So if I understand your request, it should be doable via the existing
PID1, or via a PID1 you substitute or add code to.


Steve Litt
January 2017 featured book: Troubleshooting: Just the Facts
Received on Wed Feb 01 2017 - 17:49:42 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:44:19 UTC