Closed ChanderG closed 5 years ago
Sounds interesting. Can you provide some examples of data sources that work this way?
Usually log analysis with awk. Stuff like number of entries matching a string per second or time gap in milliseconds between entries. This sort of lightweight off-line analytics on log files.
Any chance you could produce some examples that I can see how it works? I'm just a little concerned that proposed change may introduce infinite loop over closed stdin / broken pipe.
A trivial example of limited data for testing:
seq 1 100 | ttyplot
You are right about the infinite loop though, that is exactly what happens. Then, the only way to exit is to SIGINT/Ctrl-C. Better to have a sigwait based approach maybe.
In above case there never going to be any data after seq is done. Do you want ttyplot to retry reading or pause before exiting? If retry, can you send a better example that demonstrates the use case? If it's just waiting before quit you could add sleep, eg { seq 1 100; sleep 60; } | ttyplot
No retry, just like the seq example above."sleep 60" solution works too.
Do feel free to close this issue, if the feature is not of general interest.
I just want to understand the issue a little more. I don't think I have full understanding yet.
If you are plotting data that say eventually "runs out" and just want ttyplot to hang around there doing nothing, much like lets say you piped it to more or less, then perhaps an option could be added to "do not quit after pipe is closed" or something like that.
Also perhaps do send a PR so I can review the changes and understand even better :)
@ChanderG I have created a new issue #41 not to clear screen while exiting, it should be simple to implement
All uses cases where I would like to use ttyplot are with "limited" input. As it stands, ttyplot quits immediately on stdin EOF.
One simple solution that works is to replace the break statement in the
if(r<0)
codepath with asleep(10); continue;
.I can open a PR, if this is desirable.