On Thu, Oct 29, 2009 at 1:00 PM, ladislav klenovic <[email protected]> wrote:
> Hi all,
>
> we are using busybox on embedded device which uses debug console only during
> development. In this case the kernel
> argument `console' is set by uboot to appropriate serial device ttyS0 or
> ttyS1. If there is no debug console the uboot
> sets the `console=' i.e. null but still on kernel's cmdline.

What happens in this case? init has no open fds?

> These days we are wanting to upgrade from busybox 1.2.2 to 1.15.2 but we
> observed the following issue. If there is
> a debug console everything works fine however if there is no debug console
> the '/bin/sh' permanently restarts. See the
> log:
>
> Oct 29 11:23:17 192.168.200.1 init: build-date : 2009-08-28 07:34:38 UTC
> Oct 29 11:23:17 192.168.200.1 init: starting pid 524, tty '': '-/bin/sh'
> Oct 29 11:23:18 192.168.200.1 init: process '-/bin/sh' (pid 524) exited.
> Scheduling for restart.
> Oct 29 11:23:18 192.168.200.1 init: starting pid 529, tty '': '-/bin/sh'
> Oct 29 11:23:19 192.168.200.1 init: process '-/bin/sh' (pid 529) exited.
> Scheduling for restart.
> Oct 29 11:23:19 192.168.200.1 init: starting pid 539, tty '': '-/bin/sh'
> Oct 29 11:23:20 192.168.200.1 init: process '-/bin/sh' (pid 539) exited.
> Scheduling for restart.
> Oct 29 11:23:20 192.168.200.1 init: starting pid 546, tty '': '-/bin/sh'
> Oct 29 11:23:21 192.168.200.1 init: process '-/bin/sh' (pid 546) exited.
> Scheduling for restart.
> Oct 29 11:23:21 192.168.200.1 init: starting pid 555, tty '': '-/bin/sh'
> Oct 29 11:23:22 192.168.200.1 init: process '-/bin/sh' (pid 555) exited.
> Scheduling for restart.
> Oct 29 11:23:22 192.168.200.1 init: starting pid 564, tty '': '-/bin/sh'
> Oct 29 11:23:23 192.168.200.1 init: process '-/bin/sh' (pid 564) exited.
> Scheduling for restart.
> Oct 29 11:23:23 192.168.200.1 init: starting pid 571, tty '': '-/bin/sh'
> Oct 29 11:23:24 192.168.200.1 init: process '-/bin/sh' (pid 571) exited.
> Scheduling for restart.
> Oct 29 11:23:24 192.168.200.1 init: starting pid 583, tty '': '-/bin/sh'
> Oct 29 11:23:25 192.168.200.1 init: process '-/bin/sh' (pid 583) exited.
> Scheduling for restart.
> ...
>
> I did a little investigation about this and found that the latest release
> which doesn't have this
> issue is release 1.4.2. I think the problem is how the stdio is sanitized if
> there is not console.
> In older releases if the console was missing the CURRENT_VC (current virtual
> console)
> was finally set as sanitized stdio (correct me if I am wrong) however in the
> latter releases
> (after 1.4.2) the /dev/null is used which makes `/bin/sh' somehow unhappy
> and permanently
> exists.

Of course sh will exit - it sees EOF on its standard input.
Just like when you do "sh <commands" and sh reaches the end
of "commands" file.

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.

It looks like the solution is simple: if there is no console,
*dont* run the shell. It would be pointless anyway, so why
have it running?

> If I change the sanitized stdio to CURRENT_VC the problem
> disapeares.
> The patch is
> bellow. I wanted to impact the source code as less as possible so I just
> have created a new
> method bb_sanitize_stdio_current_vc().

But this is not a "sanitization" anymore. You don't open
fds 0,1,2 to a safe place, you open them to /dev/tty0.
How init knows it's safe to do that?

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

Reply via email to