How to save the tty without a buffer?

434 Views Asked by At

I'm having trouble with buffers :

I have a daemon D, and its monitor M. D is started before M, and M prints any relevant information to the tty, and I need to parse this information and give it to a program of my own.

Since I want to automate this, M should print to a file. But it doesn't until the daemon has been killed, because of buffers.

So I was thinking of recording the tty and therefore tried to use script to record the output to the terminal but ... it's buffered also ...

I also tried getting access to the gnu coreutils (to make use of stdbuf which I apparently need) but had to give up when I couldn't install the utility to unzip the peculiar .xz format proposed on GNU's website !

I fear I'm not even doing the right thing ! Isn't there a simple solution to this problem that potentially everyone who works with real-time has had ??

A little help would be much appreciated. Thanks.

1

There are 1 best solutions below

2
On
  1. the .xz file format can be extracted with xz or 7zip
  2. there appears to be a LD_PRELOAD hack to achieve the same result too: http://lists.gnu.org/archive/html/bug-coreutils/2008-11/msg00164.html

This page is my preferred reference on stdio buffering: http://www.pixelbeat.org/programming/stdio_buffering/

PS. 'everyone who works with real-time' presumably uses IPC and doesn't rely on bash. Perl, python and obviously all lower-level languages provide ways to explicitely disable/enable buffering