fbsplash

Michele Sanges michele.sanges at otomelara.it
Thu Mar 27 13:40:19 UTC 2008


Il giorno gio, 27/03/2008 alle 13.08 +0100, Denys Vlasenko ha scritto:

> On Thursday 27 March 2008 10:44, Michele Sanges wrote:
> > I'm trying the applet with the fifo; after submitting the first command,
> > the applet exits because xmalloc_fgetline returns NULL.
> > Where I am wrong?
> 
> You really should describe what exactly you are doing.
> I assume you do this:
> 
> mkfifo cmd_pipe
> setsid fbsplash -f cmd_pipe .... &
> ...
> echo 33 >cmd_pipe
> ...
> echo 66 >cmd_pipe
> ...
> 
> It will not work. Pipe's input side must not be closed!

Yes, I'm doing just this and is how it should works.

> mkfifo cmd_pipe
> setsid fbsplash -f cmd_pipe .... &
> {
> ...
> echo 33
> ...
> echo 66
> ...
> } >cmd_pipe

This applet is designed to work mainly during the system boot; is it
possible not close the fifo when the system pass from the init script of
the initrd, to the init script of root filesystem?

For me fbsplash should exits only when receive the 'exit' command, how
it worked in my last patch.

> Hmm. Your patch did this:
> 
> +       while(1) {
> +               int nVal;
> +
> +               len = read(fd, buf, 255);
> +               if (len == -1) {
> +                       DEBUG_MESSAGE("error reading the fifo");
> +                       break;
> +               }
> ...
> +       }
> 
> So it did not abort on EOF - if pipe was closed on the input side,
> it would loop, returning to read() and reading 0 bytes again and again
> (and again and again and again and again...) until somebody will
> open input side again and write someting (e.g. "exit") there,
> or task will be killed.
> 
> From one POV, it's useful behaviour (you do not need to preserve open
> fd
> on input side), OTOH eating CPU like crazy is not polite too :)
> The solution might be to close/open output side (open will block
> until there is a writer).

The pipe was opened without the O_NONBLOCK option, so the 'read' call
was blocking, I don't think it was in loop.

> Please try this patch

I go to try it.

Thanks
Michele




More information about the busybox mailing list