changeset 3252:9c784bd18858

[project @ 1999-07-15 00:33:12 by jwe]
author jwe
date Thu, 15 Jul 1999 00:34:05 +0000
parents 75e84fc9f4de
children 07d2d307c43e
files liboctave/systime.h src/ChangeLog src/sighandlers.cc src/toplev.cc
diffstat 4 files changed, 72 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/liboctave/systime.h	Thu Jul 15 00:34:05 1999 +0000
@@ -0,0 +1,43 @@
+/*
+
+Copyright (C) 1996, 1997 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#if !defined (octave_systime_h)
+#define octave_systime_h 1
+
+#ifdef TIME_WITH_SYS_TIME
+#include <sys/time.h>
+#include <time.h>
+#else
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#else
+#include <time.h>
+#endif
+#endif
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
--- a/src/ChangeLog	Wed Jul 14 22:39:37 1999 +0000
+++ b/src/ChangeLog	Thu Jul 15 00:34:05 1999 +0000
@@ -1,3 +1,18 @@
+Wed Jul 14 17:38:46 1999  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* systime.h: Move to liboctave directory.
+	* Makefile.in (INCLUDES): Delete it from the list
+
+Tue Jul 13 14:34:57 1999  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* sighandlers.cc (sigchld_handler): Only wait for processes in
+	octave_child_list.
+	* toplev.cc (cmd_status): Delete unused static variable.
+	(cmd_death_handler): Delete unused function.
+	(run_command_and_return_output): Don't add cmd_death_handler to
+	octave_child_list.  Simply extract command exit status from
+	calling close() on the procstream object.
+
 Mon Jul 12 22:38:50 1999  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* defun.h (DEFUN_MAPPER): Handle new args, d_b_map and c_b_map.
--- a/src/sighandlers.cc	Wed Jul 14 22:39:37 1999 +0000
+++ b/src/sighandlers.cc	Thu Jul 15 00:34:05 1999 +0000
@@ -208,33 +208,26 @@
 
   int n = octave_child_list::length ();
 
-  if (n == 0)
-    {
-      waitpid (-1, 0, WNOHANG);
-    }
-  else
+  for (int i = 0; i < n; i++)
     {
-      for (int i = 0; i < n; i++)
-	{
-	  octave_child& elt = octave_child_list::elem (i);
+      octave_child& elt = octave_child_list::elem (i);
+
+      pid_t pid = elt.pid;
 
-	  pid_t pid = elt.pid;
+      if (pid > 0)
+	{
+	  int status;
 
-	  if (pid > 0)
+	  if (waitpid (pid, &status, WNOHANG) > 0)
 	    {
-	      int status;
+	      elt.pid = -1;
 
-	      if (waitpid (pid, &status, WNOHANG) > 0)
-		{
-		  elt.pid = -1;
+	      octave_child::dead_child_handler f = elt.handler;
 
-		  octave_child::dead_child_handler f = elt.handler;
+	      if (f)
+		f (pid, status);
 
-		  if (f)
-		    f (pid, status);
-
-		  break;
-		}
+	      break;
 	    }
 	}
     }
--- a/src/toplev.cc	Wed Jul 14 22:39:37 1999 +0000
+++ b/src/toplev.cc	Thu Jul 15 00:34:05 1999 +0000
@@ -280,14 +280,6 @@
 
 // Execute a shell command.
 
-static int cmd_status = 0;
-
-static void
-cmd_death_handler (pid_t, int status)
-{
-  cmd_status = status;
-}
-
 static void
 cleanup_iprocstream (void *p)
 {
@@ -305,12 +297,8 @@
 
   iprocstream *cmd = new iprocstream (cmd_str.c_str ());
 
-  cmd_status = -1;
-
   if (cmd)
     {
-      octave_child_list::insert (cmd->pid (), cmd_death_handler);
-
       unwind_protect::add (cleanup_iprocstream, cmd);
 
       if (*cmd)
@@ -344,16 +332,7 @@
 	  while (cmd->get (ch))
 	    output_buf.put (ch);
 
-	  cmd->close ();
-
-	  // One way or another, cmd_death_handler should be called
-	  // when the process exits, and it will save the exit status
-	  // of the command in cmd_status.
-
-	  // The value in cmd_status is as returned by waitpid.  If
-	  // the process exited normally, extract the actual exit
-	  // status of the command.  Otherwise, return 127 as a
-	  // failure code.
+	  int cmd_status = cmd->close ();
 
 	  if (WIFEXITED (cmd_status))
 	    cmd_status = WEXITSTATUS (cmd_status);