# HG changeset patch # User John W. Eaton # Date 1251236460 14400 # Node ID c60a9e1a03727db13a5a8670dd553b7b5f7d487c # Parent d280bfa04996fa3bf2e1d02f22dea56fdb6d6d62 try to avoid gnuplot zombies diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,10 @@ +2009-08-25 John W. Eaton + + * plot/__gnuplot_open_stream__.m: Save pid in __plot_stream__ property. + * plot/gnuplot_drawnow.m: Wait for gnuplot subprocess when printing. + From Ben Abbott , Rob Mahurin , and + Dmitri Sergatskov . + 2009-08-22 David Bateman * plot/__add_datasource__.m: Correct test for "datasource" argument diff --git a/scripts/plot/__gnuplot_open_stream__.m b/scripts/plot/__gnuplot_open_stream__.m --- 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"); diff --git a/scripts/plot/gnuplot_drawnow.m b/scripts/plot/gnuplot_drawnow.m --- 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); diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2009-08-25 John W. Eaton + + * graphics.cc (gnuplot_backend::send_quit): Wait for gnuplot process. + 2009-08-24 Jaroslav Hajek * OPERATORS/op-m-m.cc: Install .*= and ./= operators. diff --git a/src/graphics.cc b/src/graphics.cc --- 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); + } } } }