This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: stdbuf does not work


On 8/18/2018 10:17 AM, Donald Krieger via cygwin wrote:
Dear Eliot,
Thanks for getting back so quickly.Program1 is a windows routine, xgraph.  http://www.xgraph.org/ms/index.htmlThis is a general purpose plotting program which writes out text whenever an operation is performed in its graphic window.
That text output is piped into Program2, a home-grown tcsh script.Program2 reads the xgraph text output one line at a time and uses it to update the display list files which xgraph is polling to keep its graphic window up to date.
Here is the test harness I'm executing inside a cygwin window. For test purposes, Program2 is cat.   stdbuf -oL -eL xgraph | cat -A
Here's a typical output which is only seen once I've terminated xgraph by clicking the appropriate button in the graphic window. The only think I did while xgraph was running was click at one location in the graphics window; that's what generated the line: Clicked at (x,y) = (-0.62324, 0.255608)
XGraph v4.38^M$Window (800 x 594)^M$0 points read.^M$^M$Error:  No dimensional data was read.  Cannot determine axes ranges.^M$^M$   Clicked at (x,y) = (-0.62324, 0.255608)^M$Exiting XGraph.^M$
I tried 0 (zero) instead of L in the stdbuf switches just because.I also tried using stdbuf -i0 Program2in case that might make a difference.
I can easily eliminate the <cr>:  stdbuf -oL -eL xgraph | tr -d "\015" | cat -AThis produces the same output but with the ^M 's removed.I don't know how to alter the windows line endings but would like to.
Thanks again and for any further thoughts.

Apparently stdbuf works by interposing stuff, via a loader PRELOAD technique,
before main in the program being run.  I suspect this simply does not work
when applied to Windows programs, though I cannot say for sure.

What about this:

xgraph ... | strbuf -oL -eL tr -d '\015' | ...

That is, apply strbuf to tr, which is a Cygwin program.  You could even apply it to cat.

Alternatively, if the xgraph of which you speak is this:

https://sourceforge.net/projects/nsnam/files/xgraph/xgraph-12.1/

you might be able to re-build it under Cygwin, though doing so sometimes requires
some adjustments to a program or its build process (though a number of programs
build out-of-the-box pretty well).  Clearly this is hardr than trying the suggestion
above :-) ...

Regards - EM

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]