On Thu, Oct 29, 2009 at 2:40 PM, Detlef Vollmann <[email protected]> wrote:
> Denys Vlasenko wrote:
>>
>> You want to run a shell on console when there is a console.
>>
>> Your problem is, when there is no console, you *still*
>> run a shell but it exits and gets repeatedly restarted.
>
> So how would you specify this in busybox inittab?

You don't specify it in inittab. If you use

::respawn:/bin/sh

init already does the most it can: it passes to /bin/sh
the same stdin/out/err kernel gave to it.

And if kernel did not (i.e., if fds 0,1,2 were closed),
then it opens them to /dev/null
(or /, if /dev/null does not exist too).

Ladislav proposes to open them to /dev/tty0 instead.
Why? And why /dev/tty0, not, say, /dev/ttyS0?

> My initial reaction was 'just don't use busybox init',
> but of course that's not always an option.

Maybe check whether stdin is a tty, and only then run sh,
otherwise sleep forever:

::respawn:/bin/run_sh_if_tty.sh

where run_sh_if_tty.sh is

#!/bin/sh
while ! tty >/dev/null 2>&1; do sleep 3600; done
exec sh "$@"

--
vda
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to