When the last writer on a fifo closes its end, the reader will see end of file. Since you are opening and closing the fifo for each line, the reader is only getting one line before seeing EOF.
Do something like this:
use FileHandle;
...
open(FIFO, ">", "named.pipe") or die "open failed; $!";
FIFO->autoflush(1);
...
for $file (@list) {
print FIFO $file, "\n";
sleep(...);
}
close(FIFO);
Or, have your reader program immediately re-open its end after it detects EOF. | [reply] [d/l] |
Yes! I made the changes you suggested and the script now works great. Many thanks... :)
| [reply] |
You might change that >> to >. Not sure what that seek to end-of-file on a pipe does, but definitely nothing useful ;-).
A close(FIFO) sends an EOF to the other side, you shouldn't close the pipe until you are finished with it (or you should expect to see those EOFs on the other side)
If this still doesn't help, post the code on the other side of the pipe, this is only half the picture
| [reply] |
Thank you for the response. I changed ">>" to ">" and moved the OPEN/CLOSE portion to outside the loop.
| [reply] |
To get error messages from your pipe add a SIG handler.
$SIG{PIPE} = sub { die "Pipe failure" };
Also you should check the exit value of any pipe closures. See perlipc under "Named Pipes" and "Using open() for IPC.
s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s
|-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,,
$|=1,select$,,$,,$,,1e-1;print;redo}
| [reply] [d/l] |
Thank you for the suggestions and the link. That looks to be a great reference for a Perl noobie like myself...
| [reply] |
open FILEHANDLE .... or die "Error opening ... $!"; | [reply] |
Thanks for the reply AM. You're right, I missed that "or" statement. Unfortunately (for me), adding it didn't change the result... :(
| [reply] |
Another point, instead of:
system("mknod named.pipe p");
You should probably use POSIX::mkfifo:
use POSIX 'mkfifo';
mkfifo 'named.pipe' or die "Cannot create FIFO 'named.pipe' $!";
| [reply] [d/l] [select] |