Mercurial > hg > octave-nkf
changeset 12073:fe30458b1de8 release-3-2-x
try to avoid gnuplot zombies
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 26 Aug 2009 08:17:08 +0200 |
parents | 33c46d112b05 |
children | e7c3e9ad2286 |
files | scripts/ChangeLog scripts/plot/__gnuplot_open_stream__.m scripts/plot/gnuplot_drawnow.m src/ChangeLog src/graphics.cc |
diffstat | 5 files changed, 28 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,10 @@ +2009-08-25 John W. Eaton <jwe@octave.org> + + * plot/__gnuplot_open_stream__.m: Save pid in __plot_stream__ property. + * plot/gnuplot_drawnow.m: Wait for gnuplot subprocess when printing. + From Ben Abbott <bpabbott@mac.com>, Rob Mahurin <rob@utk.edu>, and + Dmitri Sergatskov <dasergatskov@gmail.com>. + 2009-08-22 David Bateman <dbateman@free.fr> * plot/__add_datasource__.m: Correct test for "datasource" argument
--- a/scripts/plot/__gnuplot_open_stream__.m +++ b/scripts/plot/__gnuplot_open_stream__.m @@ -28,6 +28,8 @@ [plot_stream(1), plot_stream(2), pid] = popen2 (cmd); if (pid < 0) error ("__gnuplot_open_stream__: failed to open connection to gnuplot."); + else + plot_stream(3) = pid; endif else plot_stream = popen (cmd, "w");
--- a/scripts/plot/gnuplot_drawnow.m +++ b/scripts/plot/gnuplot_drawnow.m @@ -67,9 +67,12 @@ set (h, "__plot_stream__", default_plot_stream); if (! isempty (plot_stream)) pclose (plot_stream(1)); - if (numel (plot_stream) == 2) + if (numel (plot_stream) > 1) pclose (plot_stream(2)); endif + if (numel (plot_stream) > 2) + waitpid (plot_stream(3)); + endif endif if (! isempty (fid)) fclose (fid);
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2009-08-25 John W. Eaton <jwe@octave.org> + + * graphics.cc (gnuplot_backend::send_quit): Wait for gnuplot process. + 2009-08-12 Jaroslav Hajek <highegg@gmail.com> * data.cc (Fissorted, F__sort_rows_idx__, Fnorm): Mark as Built-in
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -2033,7 +2033,7 @@ private: void send_quit (const octave_value& pstream) const { - if (! pstream.is_empty()) + if (! pstream.is_empty ()) { octave_value_list args; Matrix fids = pstream.matrix_value (); @@ -2041,15 +2041,23 @@ if (! error_state) { args(1) = "\nquit;\n"; - args(0) = octave_value (fids (0)); + args(0) = fids(0); feval ("fputs", args); + args.resize (1); feval ("fflush", args); feval ("pclose", args); + if (fids.numel () > 1) { - args(0) = octave_value (fids (1)); + args(0) = fids(1); feval ("pclose", args); + + if (fids.numel () > 2) + { + args(0) = fids(2); + feval ("waitpid", args); + } } } }