Patch: zombie removal

Tom Tromey tromey@cygnus.com
Tue May 30 16:25:00 GMT 2000


I'm checking this in.  This patch makes it so that zombies aren't left
around by the demangling of stack traces.

2000-05-30  Tom Tromey  <tromey@cygnus.com>

	* include/name-finder.h: Include <sys/wait.h>.
	(_Jv_name_finder::pid): Now of type `pid_t'.
	(_Jv_name_finder::~_Jv_name_finder): Call waitpid().
	* java/lang/Throwable.java (CPlusPlusDemangler.close): Call
	`proc.waitFor()'.

Tom

Index: name-finder.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/name-finder.cc,v
retrieving revision 1.3
diff -u -r1.3 name-finder.cc
--- name-finder.cc	2000/05/19 17:55:27	1.3
+++ name-finder.cc	2000/05/30 23:24:48
@@ -78,7 +78,7 @@
 
   error |= pipe (f_pipe) < 0;
   error |= pipe (b_pipe) < 0;
-      
+
   if (error)
     return;
 
@@ -92,16 +92,16 @@
       execvp (argv[0], argv);
       _exit (127);
     }
-      
+
   close (f_pipe [0]);
   close (b_pipe [1]);
-      
+
   if (pid < 0)
     {
       error |= 1; 
       return;
     }
-      
+
   b_pipe_fd = fdopen (b_pipe[0], "r");
   error |= !b_pipe_fd;
 #endif
Index: include/name-finder.h
===================================================================
RCS file: /cvs/java/libgcj/libjava/include/name-finder.h,v
retrieving revision 1.1
diff -u -r1.1 name-finder.h
--- name-finder.h	2000/01/17 15:43:32	1.1
+++ name-finder.h	2000/05/30 23:24:48
@@ -17,6 +17,7 @@
 #include <jvm.h>
 
 #include <sys/types.h>
+#include <sys/wait.h>
 
 #include <string.h>
 #include <stdio.h>
@@ -38,8 +39,12 @@
 #if defined (HAVE_PIPE) && defined (HAVE_FORK)
       close (f_pipe[1]);
       fclose (b_pipe_fd);
+
+      int wstat;
+      // We don't care about errors here.
+      waitpid (pid, &wstat, 0);
 #endif
-    }  
+    }
 
 /* Given a pointer to a function or method, try to convert it into a
    name and the appropriate line and source file.  The caller passes
@@ -60,10 +65,9 @@
 private:
   void toHex (void *p);
 #if defined (HAVE_PIPE) && defined (HAVE_FORK)
-  int pid;
+  pid_t pid;
   int f_pipe[2], b_pipe[2];
   FILE *b_pipe_fd;
   int error;
 #endif
 };
-
Index: java/lang/Throwable.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/lang/Throwable.java,v
retrieving revision 1.5
diff -u -r1.5 Throwable.java
--- Throwable.java	2000/03/07 19:55:26	1.5
+++ Throwable.java	2000/05/30 23:24:49
@@ -88,6 +88,13 @@
 	written++;
       }
     p.flush ();
+    try
+      {
+	proc.waitFor ();
+      }
+    catch (InterruptedException _)
+      {
+      }
   }    
 }
 


More information about the Java-patches mailing list