Bug 1244 testcase

Denis Vlasenko vda.linux at googlemail.com
Sun Mar 4 22:20:05 UTC 2007


On Sunday 04 March 2007 20:39, Eric Spakman wrote:
> >> It's indeed strange that some daemons seem to need a controlling tty,
> >> at least dnsmasq, openntpd and ulogd won't start without and I can
> >> imagine
> >
> > I suspect that daemons don't need it, but some script probably fails
> > before they have a chance to be started.
> >
> > In order to find out where it breaks down, do *NOT* use cttyhack,
> > but use "exec >/dev/tty1 2>/dev/tty1 </dev/tty1" trick. Move it further and
> > further down the script until you find the place where script starts to
> > fail.
> >
> I tried it and some scripts indeed start to fail with the latest SVN
> version. All those scripts contain "set -e". Commenting that out make the
> script run again.
> 
> A snippet:
> 
> set -e
> 
> case "$1" in
>   start)
>         echo -n "Starting $DESC: "
>         start-stop-daemon --quiet --start --exec $DAEMON -- -d > /dev/null
> 2>&1
>         echo "$NAME."
>         ;;
> 
> 
> But the console is still quiet, I need the cttyhack program to show any
> init bootmessages on the screen.

I have an idea what's going on. Your initrd stars /sbin/init this way:
...; exec /sbin/init <dev/console >dev/console 2>dev/console
It seems '<' redirection is opened in O_RDONLY mode by shell
(both ash and bash).

Then init does this:

       close(1);
       close(2);
       set_term();
       dup(0);
       dup(0);

Guess what? Our fd #1 and #2 are _not_ writable_ after that!
I managed to add statically linked strace into your image
and it definitely shows that "/bin/echo TEST" fails to write(1, ...).

Please try attached fix.

Sorry.
--
vda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 3.patch
Type: text/x-diff
Size: 1321 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20070304/45d82669/attachment-0002.bin 


More information about the busybox mailing list