0

I have an application (A) that updates some data (about 1 MB) every second. I can make this application write the data to a file of my choosing, but other than that it is out of my control.

I need to read this data (entirely) in another application (B). This application is mine so I can code it however I want.

So my question is: What is the appropriate way sharing the data between application A and B? I don't need the data to be retained in memory longer than it takes for application B to read it (on a reboot or whatever). I only need access to the fresh data if application A is running.

My current solution is: Make application A write to /dev/shm/myapplication every second. Code application B so that it reads from /dev/shm/myapplication once every second. It works, but I am still curious if this is the "proper" way of doing it. Other answers and comments have lead me to believe that "/dev/shm" is a bad place for tinkering. See these sources:

https://superuser.com/a/227714/359316

https://stackoverflow.com/a/42884337/2583765

birgersp
  • 143
  • 10
  • 1
    Slighty out of my area of expertise, but I suspect the solutio n you are looking for is called a "named pipe" – davidgo Jan 17 '22 at 09:46
  • 2
    For small amounts of ephemeral data I beliebe /dev/shm is entirely appropriate. – davidgo Jan 17 '22 at 09:47
  • @davidgo: As I mentioned application A writes to file and there isn't really much I can do about that. How would I use a pipe on a file? Do you mean to read the file with `cat` and pipe that to my application somehow? – birgersp Jan 17 '22 at 09:52
  • 1
    No. I mean create a **named** pipe - this appears as a file in the filesystem. Then program A can write to the named pipe (which it sees as a file) and program B can read from it. Again im not an expert on named pipes - but it seems like something you should read up on. (hence a comment, not an answer) – davidgo Jan 17 '22 at 10:32
  • The advantage should be that you would get the information as it comes in. Right now by getting out of sync and/or operations taking slightly longer you might end up not "seeing" data with your application. – Seth Jan 17 '22 at 12:40

0 Answers0