diff src/sighandlers.cc @ 1230:92609e161b29

[project @ 1995-04-10 01:08:57 by jwe]
author jwe
date Mon, 10 Apr 1995 01:14:34 +0000
parents dfe01093f657
children 611d403c7f3d
line wrap: on
line diff
--- a/src/sighandlers.cc	Mon Apr 10 01:04:46 1995 +0000
+++ b/src/sighandlers.cc	Mon Apr 10 01:14:34 1995 +0000
@@ -22,15 +22,17 @@
 */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
 #include <sys/types.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
+#include <sys/wait.h>
 #include <new.h>
 #include <signal.h>
+#include <iostream.h>
 
 #include "sighandlers.h"
 #include "octave.h"
@@ -72,6 +74,47 @@
 #endif
 }
 
+// Handle SIGCHLD.  Should use waitpid and ignore stopped jobs.
+// Needs to restore state of plotter such that it will be restarted
+// again when needed.  Needs to close file descriptors corresponding
+// to processes started with execute().
+
+#if 0
+static RETSIGTYPE
+sigchld_handler (int i)
+{
+  int status;
+  pid_t pid = wait (&status);
+
+  if (pid < 0)
+    cerr << "wait error\n";
+  else
+    {
+      cerr << "sigchld caught, PID = " << pid << "; status: ";
+
+      int lo_byte = (status & 0xff);
+      int hi_byte = ((status >> 8) & 0xff);
+      if (lo_byte == 0177)
+	{
+	  cerr << "stopped with signal = " << hi_byte << "\n";
+	}
+      else if (lo_byte)
+	{
+	  int sig_num = (lo_byte & 0x7f);
+	  cerr << "stopped with signal = " << sig_num << "\n";
+	  if (lo_byte & 0200)
+	    cerr << "child dumped core\n";
+	}
+      else
+	{
+	  cerr << "exited with status = " << hi_byte << "\n";
+	}
+    }
+
+  signal (SIGCHLD, sigchld_handler);
+}
+#endif
+
 // Handle SIGINT by restarting the parser (see octave.cc).
 
 // XXX FIXME XXX -- it would probably be good to try to use POSIX
@@ -139,6 +182,12 @@
   signal (SIGBUS, generic_sig_handler);
 #endif
 
+#if 0
+#ifdef SIGCHLD
+  signal (SIGCHLD, sigchld_handler);
+#endif
+#endif
+
 #ifdef SIGEMT
   signal (SIGEMT, generic_sig_handler);
 #endif