[R] Making fifo work (Linux)

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Mon Dec 10 01:23:04 CET 2012


Your problem seems to be unfamiliarity with this operating-system-specific feature. You should be reading the OS documentation (e.g. "man fifo" and learning how to use the feature in general before using it in R. (Hint: off-topic here.)

Some words to the wise: Make sure you test with two processes, one for reading, one for writing (this is not a storage medium, it is an inter-process communication mechanism). Make sure you define a specific number of lines (e.g. 1) when you read unless you want to wait until the writing process closes the fifo.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

Worik R <worikr at gmail.com> wrote:

>Friends
>
>I need to get R reading from a fifo. I want it to block till there is
>some
>data in the fifo, consume what input it gets there, do some thing with
>it
>then loop back and block again.
>
>Very simple.  Yes?  No.
>
>The example in the documentation works OK..
>
>       zz <- fifo("foo-fifo", "w+")
>       writeLines("abc", zz)
>       print(readLines(zz))
>       close(zz)
>       unlink("foo-fifo")
>
>But when I tryu my code to *read* and *block*, id does not work.
>
>P <- "Myfoofifo"
>C <- fifo(P, "r", blocking=TRUE)
>
>If Myfoofifo does not exist this has an error:
>
>> C <- fifo(P, "r", blocking=TRUE)
>Error in fifo(P, "r", blocking = TRUE) : cannot open the connection
>In addition: Warning message:
>In fifo(P, "r", blocking = TRUE) : cannot open fifo 'Myfoofifo'
>>
>
>> C <- fifo(P, "w+", blocking=TRUE)
>
>succeeds but a read...
>
>> Z <- readLines(C)
>
>hangs.  Writing to Myfoofifo from other programmes, opening closing
>even
>deleting it makes no difference.
>
>I am stuck.  I can find no pertinent  examples.  What can I do?
>
>Worik
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list