fbsplash
Denys Vlasenko
vda.linux at googlemail.com
Thu Mar 27 12:08:19 UTC 2008
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!
mkfifo cmd_pipe
setsid fbsplash -f cmd_pipe .... &
{
...
echo 33
...
echo 66
...
} >cmd_pipe
Proof:
On one console:
bash-3.2# cd /tmp
bash-3.2# mkfifo zzz
bash-3.2# strace -tt cat zzz
12:56:20.891968 execve("/bin/cat", ["cat", "zzz"], [/* 32 vars */]) = 0
...
12:56:20.893027 open("zzz", O_RDONLY|O_LARGEFILE) = 3
12:56:25.709517 read(3, "TEST\n", 65536) = 5
12:56:25.710465 write(1, "TEST\n", 5TEST
) = 5
12:56:25.710542 read(3, "", 65536) = 0 <========== EOF from pipe!
12:56:25.711353 close(3) = 0
12:56:25.711426 _exit(0) = ?
On other console:
bash-3.2# cd /tmp
bash-3.2# echo TEST >TEST
bash-3.2# strace -tt cp TEST zzz
12:56:25.707015 execve("/bin/cp", ["cp", "TEST", "zzz"], [/* 32 vars */]) = 0
...
12:56:25.709129 open("TEST", O_RDONLY|O_LARGEFILE) = 3
12:56:25.709329 open("zzz", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0100644) = 4
12:56:25.710133 read(3, "TEST\n", 65536) = 5
12:56:25.710340 write(4, "TEST\n", 5) = 5
12:56:25.710809 read(3, "", 65536) = 0
12:56:25.711195 close(4) = 0 <========== this made other side see EOF!
12:56:25.712051 close(3) = 0
12:56:25.712243 _exit(0) = ?
See? Pay attention to timestamps.
12:56:25.710542 - output side called read(), it blocked (no data available, and no EOF yet)
12:56:25.711195 - input side closed fd
12:56:25.711353(actually a bit earlier) - output side saw EOF
12:56:25.712051 - input side continues execution
Even if input side opened fifo again immediately after close(),
it will be too late. Output side already saw EOF.
--
vda
More information about the busybox
mailing list