inittab: Start shell only if console is not null

Denys Vlasenko vda.linux at googlemail.com
Thu Aug 28 09:05:36 UTC 2014


On Thu, Aug 28, 2014 at 10:08 AM, Guillermo Rodriguez Garcia
<guille.rodriguez at gmail.com> wrote:
> 2014-08-28 9:58 GMT+02:00 Harald Becker <ralda at gmx.de>:
>>> console::respawn:/sbin/getty -L 115200 ttyS0 vt100
>>>
>>
>> This is a special Busybox feature. BB uses the id field to specify a tty
>> device, used to start the inittab command.
>
> Yes I knew this.
>
>> If the device open fails, the inittab line is skipped.
>
> But I didn't know this. So it seems that if I use "console" as the id,
> the device open succeeds when the system boots with console=ttyS0 but
> fails when booting with console=null (not sure why -- shouldn't it be
> possible to open /dev/null ?).
>
> Is my understanding correct?

init won't try to open /dev/null for
"console::respawn:/sbin/getty -L 115200 ttyS0 vt100"
line. It will try to open /dev/console.
If that open fails, then respawning will not be done.

Therefore, your question should be
"why when I boot my kernel with console=null,
/dev/console can't be opened?"

> And, if this is indeed correct, then why leaving the id empty works
> even when booting with console=null ?

The "::respawn:/sbin/getty -L 115200 ttyS0 vt100" line
(empty id case) does not try to open anything.
It just uses already-opened file descriptors 0,1,2 for stdio.
It can't "fail to open /dev/something" since it does not open anything.

(Note that init does ensure that file descriptors 0,1,2 are open
even if they weren't open when it was started by kernel.
See console_init() in the source).

-- 
vda


More information about the busybox mailing list