diff src/graphics.cc @ 9561:c60a9e1a0372

try to avoid gnuplot zombies
author John W. Eaton <jwe@octave.org>
date Tue, 25 Aug 2009 17:41:00 -0400
parents ee8a035f3997
children bdcfb756d721
line wrap: on
line diff
--- 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);
+		    }
 		}
 	    }
 	}