[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Read line length
- From: William Ahern <william@...>
- Date: Tue, 22 Oct 2013 07:34:54 -0700
On Tue, Oct 22, 2013 at 04:33:15AM -0700, Jose Torre-Bueno wrote:
<snip>
> This is in OSX. My intent is to create a file which serves as a
> combination of a log and a fifo so one program is adding lines that when
> put through loadstring yield a table and another program is reading the
> file and whenever a line is added it gets the most current version of the
> table. When there is only one version of the table and it is exchanged
> between two programs by writing a file and reading it with loadfile this
> works, I had thought to write the code as a single line with line
> buffering and use the file pointer as the mechanism for the reader to know
> if there were a new version of the table.
You need some sort of locking strategy otherwise you'll run into atomicity
issues. I.e. process A attempts to write a line of length N, but internally
the writes are split into 2 syscalls of N/2. Process B attempts to read the
file and only sees the first fragment before it reaches EOF and returns.
This sounds like maybe an output buffering problem, not input buffering. But
note that there's an upper limit to the maximum atomic write.