# HG changeset patch # User John W. Eaton # Date 1251267428 -7200 # Node ID fe30458b1de801fe2a4aac2a02ecd458c01c981a # Parent 33c46d112b0522541470d7a26484bb37e44547ac 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 (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"); 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-12 Jaroslav Hajek * data.cc (Fissorted, F__sort_rows_idx__, Fnorm): Mark as Built-in diff --git a/src/graphics.cc b/src/graphics.cc --- 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); + } } } }