|Justin Walker on Thu, 08 Jan 2004 21:18:47 +0100|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
|Re: Using fifos for in/output|
To add to the discussion: On Thursday, January 8, 2004, at 06:15 AM, Prof. J. E. Cremona wrote: [snip]
As a first test, I tried this but it doesn't work: 1. Create fifos called gpin and gpout. 2. (In window 1) start gp with gp -q -f < gpin > gpout 3. (In window 2) In a separate window do tail -f gpout 4. (In window 3) In a 3rd window do cat >> gpin And then I would hope that any gp input lines I type into window 3 will be processed by gp and the output seen in window 2.
On Mac OS X, I see exactly what you would expect, if I use 'cat'. If I use 'tail -f', then it sometimes works. The failures seem to be random, but with success intermittent and infrequent.
I think that the problem is due to the behavior of 'tail', combined with (possible) quirks in the implementation [or, perhaps, design] of fifos. 'tail -f' sleeps, and checks the modification time of the file it's reading, at intervals.
FWIW: - 'cat' will continue to read the fifo until you terminate the 'gp' session, so that gives you the experience you want. - if 'tail -f' is in "recalcitrant mode", when it finally wakes up, it literally gives you the tail of the output (if there's a lot of queued-up stuff, only the last part gets displayed), so even if it worked, if you are producing lots of output in a short time, 'tail' will not show you everything.At this point, I have no good explanation. What system are you using? If you have the time, it would be interesting to see what happens when you try the various orders of startup.
Regards, Justin -- /~\ The ASCII Justin C. Walker, Curmudgeon-at-Large \ / Ribbon Campaign X Help cure HTML Email / \