Re: execline's pipeline (and forbacktickx) with closed stdin

From: Guillermo <>
Date: Sun, 10 May 2015 15:14:50 -0300

Laurent Bercot <> wrote:
> Did you really manage to umount /dev (maybe) and mount a tmpfs
> over it (for sure) with fds still open to the old /dev ? Without
> an EBUSY error ? If it's the case, and you're using Linux, then the
> kernel's behaviour changed.

Yeah, it's Linux. A Gentoo virtual machine with kernel version 3.14
(plus Gentoo patches).

It has sysvinit + OpenRC, one of the two officialy supported
configurations (the other one being systemd), and I tried to replace
it with s6 and keep OpenRC for oneshot initializations tasks, since,
well, they are already written :) Long-lived processes have an actual
servicedir in process 1 s6-svscan's scandir, OpenRC would otherwise
launch them unsupervised.

I mostly followed the example init scripts, but I did deviate, among
other things to delegate tasks to OpenRC (as a bundle of oneshot
services in s6-rc terminology, hehe). And now that you remind me they
were originally there, I don't have the fdclose 1 and fdclose 2 in
stage 1 either. I wanted the stage 2 init to have open FDs to
/dev/console, to show OpenRC's output.

The /dev handling is taken care of by an OpenRC-provided oneshot
service in its sysinit runlevel, called "devfs". It mounts a devtmpfs
(or tmpfs, depending on kernel configuration) on /dev, and creates
some essential device nodes. The rest is left to an udev daemon. So
the kernel needs either CONFIG_DEVTMPFS=y (Gentoo's default) or
CONFIG_TMPFS=y. The devfs service does the equivalent of a "mount -t
devtmps dev /dev", or a "mount -t devtmps -o remount dev /dev" if
there is a filesystem already mounted at /dev. No kernel complaints
when sysvinit is process 1 (I don't know what it does with its open
FDs), no kernel complaints with the custom stage 1 init having devfs
start with open FDs to /dev/console and /dev/null.

There is no unmounting /dev (maybe that's specifically what would
trigger an EBUSY?). The kernel has CONFIG_DEVTMPFS_MOUNT=n, so no
devtmpfs is mounted after the rootfs. And when I boot with
init=/bin/bash, "mount" shows nothing but / and a manually mounted
/proc. However, /dev is not empty. I don't know where the device nodes
came from, but they are there. I didn't create them, maybe they were
put in there during Gentoo's installation, I don't know. I fact, the
after boot /dev looks quite different (and I do see a devtmpfs
mounted). A "mount --bind / /tmp" shows me the original boot time
/dev, so I suppose the root FS has actual static device nodes.

The bottom line is, I'm not entirely sure what magic is involved, but
everyting worked :)

          |-VBoxClient---{X11 monitor}
          |-VBoxClient---{Host events}
          | `-{X11-NOTIFY}
          | `-sh---openbox
          | |-{control}
          | |-{cpuhotplug}
          | |-{memballoon}
          | |-{timesync}
          | |-{vminfo}
          | `-{vmstats}

Received on Sun May 10 2015 - 18:14:50 UTC

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