Reading from text file during write on it
-
Is it possible with 2 separate programs to read and write data in a single file at same time? One of those is added data to the text file with thread , and the other program reads information with thread from the same file at the same time, the added data is always in progress, but reading data can be done every few seconds. Is it possible?
-
Hi,
Are you thinking of something like the
tail -f
Linux command ? -
It's possible (on linux), but the point is your design choice is bad. You should use something (i.e. @JonB's IPC) that you have control over. What would happen if I delete or move the file while you're reading or writing? What'd you expect to see in the moved file, after the reading/writing completed ...?
-
@kshegunov I use QT on Raspberry Pi with raspbian OS,I tested tail command and it's ok, for some reason I used two programs and I want to read data of text file and send it to the web server with QHttp protocol( not sending all data at one time), I need to save data in Pi memory
-
This examples uses a buffer in memory but the concept is identical with files