Mercurial > hg > octave-lyh
changeset 9561:c60a9e1a0372
try to avoid gnuplot zombies
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 25 Aug 2009 17:41:00 -0400 |
parents | d280bfa04996 |
children | b8db3595f706 |
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 (prog, args{:}); if (pid < 0) error ("__gnuplot_open_stream__: failed to open connection to gnuplot."); + else + plot_stream(3) = pid; endif else plot_stream = popen (sprintf ("%s ", prog, args{:}), "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-24 Jaroslav Hajek <highegg@gmail.com> * OPERATORS/op-m-m.cc: Install .*= and ./= operators.
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -2042,7 +2042,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 (); @@ -2050,15 +2050,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); + } } } }