Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to detect whether the gnuplot terminal is still running? #62

Closed
wucke13 opened this issue Apr 17, 2020 · 4 comments
Closed

How to detect whether the gnuplot terminal is still running? #62

wucke13 opened this issue Apr 17, 2020 · 4 comments

Comments

@wucke13
Copy link

wucke13 commented Apr 17, 2020

I want my rust code to loop {} until the plot window is closed. How do I do this?

This is needed, as most gnuplot terminals loose control facilities if the their gnuplot process dies, which always happens if the rust program which spawned gnuplot dies. So in order to have that rust program wait for the gnuplot terminal to terminate, one needs to know whether gnuplot is still running.

@SiegeLord
Copy link
Owner

Currently we interact with gnuplot as follows:

  1. We spawn it using its --persist flag.
  2. We issue the quit command when Figure is dropped.

(2) was added to kill zombie gnuplot processes that (1) sometimes created. It sounds like we need this to be configurable, either by altering (1) or (2).

I just experimented with this a little bit, and this appears to work:

  1. Issue pause mouse close
  2. Issue quit.
  3. Check if gnuplot is closed via Process::try_wait.

If you don't do (1), then gnuplot exits right away. If you don't do (2), gnuplot never exits.

I guess (1) can be done via Figure::set_post_commands, so the only thing missing is a version of Figure::close that does a try_wait rather than wait.

@wucke13
Copy link
Author

wucke13 commented Apr 18, 2020

Hi & thank you for the detailed analysis. I'm fine with whatever solution you prefer. However, a more intuitive solution than having to set the pre and post commands would be preferabl IMHO. I think the best would be a function which just tells whether gnuplot is still running. This would allow for a non blocking wait on gnuplot.

@SiegeLord
Copy link
Owner

Yeah, I'll see what can be done. Another issue is that even if I fix this, some things still fail to work correctly with the UI (like multiplot).

@SiegeLord
Copy link
Owner

With 52016af, show now returns a CloseSentinel that you can call wait or try_wait to determine if the gnuplot process is still running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants