Let's say I open a file a for reading. What if an application, let's call it aWriter writes to this file in random intervals. Are there any possibilities of me receiving improper file contents if I try to open a for a read and at the same time aWriter is writing a new line. What happens to the file and what happens to what I get from my read.
Another scenario. Let's say I have a file b which contains 100 lines of text. I also have an application bWriter which writes to b at random times. I want to remove the first 80 lines of file b. Let's assume bWriter wants to write to b as I have it open, will it still be able to write? Will it give up and lose it's write?
I ask because I'm writing a Perl script which ties into Syslog. I've pointed Syslog to write all logs to a file and my script needs to (every 5 minutes) read the contents of the file, do some other stuff, then remove all the lines in that file and write the old lines to an archive. I'm using the file as an intermediary step between my script and the final resting place for logs.
Can anyone give me some insight on to how exactly this works?