changeset 2211:71aef7b5339e

[project @ 1996-05-15 13:00:17 by jwe]
author jwe
date Wed, 15 May 1996 13:00:17 +0000
parents a3e39f8efed2
children fa855f4aae30
files src/pt-plot.cc
diffstat 1 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/pt-plot.cc	Wed May 15 12:56:15 1996 +0000
+++ b/src/pt-plot.cc	Wed May 15 13:00:17 1996 +0000
@@ -90,6 +90,9 @@
 // Pipe to gnuplot.
 static oprocstream *plot_stream = 0;
 
+// ID of the plotter process.
+static pid_t plot_stream_pid = 0;
+
 // Use shortest possible abbreviations to minimize trouble caused by
 // gnuplot's fixed-length command line buffer.
 
@@ -126,8 +129,6 @@
   warning ("please try your plot command(s) again");
 }
 
-static sig_handler *saved_sigint_handler = 0;
-
 static void
 open_plot_stream (void)
 {
@@ -153,12 +154,16 @@
       // XXX FIXME XXX -- I'm not sure this is the right thing to do,
       // but without it, C-c at the octave prompt will kill gnuplot...
 
-      saved_sigint_handler = octave_set_signal_handler (SIGINT, SIG_IGN);
+#if defined (HAVE_POSIX_SIGNALS)
+      sigset_t set, oset;
+      sigemptyset (&set);
+      sigaddset (&set, SIGCHLD);
+      sigaddset (&set, SIGINT);
+      sigprocmask (SIG_BLOCK, &set, &oset);
+#endif
 
       plot_stream = new oprocstream (plot_prog.c_str ());
 
-      octave_set_signal_handler (SIGINT, saved_sigint_handler);
-
       if (plot_stream)
 	{
 	  if (! *plot_stream)
@@ -170,12 +175,17 @@
 	    }
 	  else
 	    {
-	      pid_t id = plot_stream->pid ();
-    	      octave_child_list::insert (id, plot_stream_death_handler);
+	      plot_stream_pid = plot_stream->pid ();
+    	      octave_child_list::insert (plot_stream_pid,
+					 plot_stream_death_handler);
 	    }
 	}
       else
 	error ("plot: unable to open pipe to `%s'", plot_prog.c_str ());
+
+#if defined (HAVE_POSIX_SIGNALS)
+      sigprocmask (SIG_SETMASK, &oset, 0);
+#endif
     }
 
   if (! error_state && plot_stream && *plot_stream && ! initialized)
@@ -861,6 +871,8 @@
 void
 close_plot_stream (void)
 {
+  octave_child_list::remove (plot_stream_pid);
+
   if (plot_stream)
     {
       delete plot_stream;