confusing behavior with no inittab and non-tty stdin

Denys Vlasenko vda.linux at googlemail.com
Fri Nov 6 16:00:32 UTC 2015


On Thu, Nov 5, 2015 at 6:33 AM, Tycho Andersen
<tycho.andersen at canonical.com> wrote:
> Hi all,
>
> I'm experiencing some confusing behavior with busybox when running it
> in an LXC container. In particular, this means that stdin, stdout, and
> stderr are all /dev/null when busybox is exec()'d as init.
>
> It seems as though busybox re-opens stdin as /dev/zero (I can't quite
> find where this happens), and then since there is no init tab does a,
>
> new_init_action(ASKFIRST, bb_default_login_shell, "");
>
> which then proceeds to spin forever, because /dev/zero never returns a
> \n.
>
> I'm not sure what the right fix is here (there is a comment about
> using VC_1 instead of "" there), but the current behavior doesn't seem
> ideal.
>
> Thoughts?

Normal init's stdin/out/err is opened by kernel to whatever console device
is specified on kernel's command line, or chosen by kernel by default -
it's the same device where all boot-time kernel messages are seen.

By default, busybox init will not open any new devices for console -
it will use fds 0,1,2 as prepared by kernel. Setting CONSOLE=/dev/foo
or console=/dev/foo overrides it.

Looks like LXC container (or its particular configuration you are using)
is not opening init's stdin/out/err to a suitable device.


More information about the busybox mailing list