0

I would like to do the following :

I want to imple,ment the concept of FIFO in normal files using GUILE.

Two processes should communicate via a normal text file, that a third process , if needed, can access.

The subordinate of the original two processes should write in the file, line after line, that is append. So far so good. (implemented in c++)

The master proces however, should treat this file as a FIFO, it should read the first line, and do somethong corresponding to it, and delete the first line leaving the rest intact.

The problems are :

  1. While the Master is accessing the file, the subordinate may come to a point where it must write there, leading to a conflict.
  2. Popping the first line may need reading the whole ile out, in a string, poping the first thereof, and then saving it, which is memory intensive, and the second saving action may again conflict with the child trying to write there,

I wanted to implement this in GUILE, because since it is the official OS extension language, there might be better ways which addresses the above two issues.

But in the web I do not find much to orient myself. Please help, sorry for the lewss than concrete question, then I dont have a code snippet to show.

Sean
  • 789
  • 6
  • 26
  • Why are you doing this using regular files instead of using a real fifo? Since you have only one reader process, a fifo does sound like the ideal solution. Remember, it's easy to make named fifos using `mkfifo`. – C. K. Young Nov 12 '13 at 16:57
  • because a. I want eventhird applications, besides the communicators to access the file and monitor what is going on, and b. if the applications say crash, then I can look in the regular file and seewhat the messages were transported before crash – Sean Nov 12 '13 at 18:58
  • 1
    You can use `tee` to send the fifo's output into a file. Then your main application would still be reading from and writing to a pipe, not a regular file. – C. K. Young Nov 13 '13 at 01:02
  • that is a good hint, that you very much – Sean Nov 13 '13 at 21:57

0 Answers0