Just in case anyone else has this issue i have been on an extensive search and come to the conclusion it is not possible due to kernel implementation etc ...
I wrote the following work around to do what i wanted. I created two files: textFilter.py and getLatest.py. Essentially you run ./loopPrinting.sh | python textFilter.py and get the Latest 100 lines. I am reasonably sure this is atomic and reliable (though if it isn't please tell me!!!). It creates 16 files and changes the count (similar to the apple live streaming i think).
textFilter.py
import sys
import os
import time
def mainLoop(size):
myBuffer = [0]*size
count = 0
while True:
for i in range(size):
myBuffer[i] = sys.stdin.readline()
f = open('/home/development/textFilter/' + repr(count) + '.dat', 'w')
f.write(''.join(myBuffer))
f.close()
f = open('/home/development/textFilter/count.dat~', 'w')
f.write(repr(count))
f.flush()
os.fsync(f.fileno())
f.close()
time.sleep(0.01)
os.rename('/home/development/textFilter/count.dat~','/home/development/textFilter/count.dat')
count += 1
count = count % 16
if __name__ == "__main__":
try:
mainLoop(int(sys.argv[1]))
except Exception:
mainLoop(100)
getLatest.py
import sys
import time
def getData():
f = open('count.dat', 'r')
count = f.read()
f.close()
count = int(count)
oldCount = count
while oldCount == count:
time.sleep(0.1)
f = open('count.dat', 'r')
count = f.read()
f.close()
count = int(count)
f = open(repr(count) + '.dat', 'r')
data = f.readlines()
f.close()
for row in data:
print row,
return 0
if __name__ == "__main__":
try:
getData()
except Exception as inst:
sys.stderr.write('ERROR')
sys.stderr.write(inst)