[kaffe] CVS kaffe (kaz): libraries/javalib/kaffe/lang/UNIXProcess.java:

Kaffe CVS cvs-commits at kaffe.org
Tue Jun 8 14:16:02 PDT 2004


PatchSet 4831 
Date: 2004/06/08 21:11:06
Author: kaz
Branch: HEAD
Tag: (none) 
Log:
2004-06-09  Ito Kazumitsu  <kaz at ph.maczuka.gcd.org>

	* libraries/javalib/kaffe/lang/UNIXProcess.java:
	Close the internal stream sync when the subprocess is finished.
	Close input/output streams in the method finalize().

Members: 
	ChangeLog:1.2399->1.2400 
	libraries/javalib/kaffe/lang/UNIXProcess.java:1.18->1.19 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2399 kaffe/ChangeLog:1.2400
--- kaffe/ChangeLog:1.2399	Mon Jun  7 19:14:07 2004
+++ kaffe/ChangeLog	Tue Jun  8 21:11:06 2004
@@ -1,3 +1,9 @@
+2004-06-09  Ito Kazumitsu  <kaz at ph.maczuka.gcd.org>
+
+	* libraries/javalib/kaffe/lang/UNIXProcess.java:
+	Close the internal stream sync when the subprocess is finished.
+	Close input/output streams in the method finalize().
+
 2004-06-07  Guilhem Lavaux <guilhem at kaffe.org>
 
 	* configure.ac: Check for setrlimit. Fixed typo.
Index: kaffe/libraries/javalib/kaffe/lang/UNIXProcess.java
diff -u kaffe/libraries/javalib/kaffe/lang/UNIXProcess.java:1.18 kaffe/libraries/javalib/kaffe/lang/UNIXProcess.java:1.19
--- kaffe/libraries/javalib/kaffe/lang/UNIXProcess.java:1.18	Mon Apr 12 11:40:33 2004
+++ kaffe/libraries/javalib/kaffe/lang/UNIXProcess.java	Tue Jun  8 21:11:08 2004
@@ -34,6 +34,7 @@
 	OutputStream stdin_stream;
 	InputStream raw_stdout;
 	InputStream raw_stderr;
+	FileOutputStream sync;
 	Throwable throwable;		// saved to rethrow in correct thread
 
 public UNIXProcess(final String argv[], final String arge[], File dir)
@@ -75,6 +76,7 @@
 				this.notifyAll();
 			}
 			synchronized(UNIXProcess.this) {
+				try_close(sync);
 				UNIXProcess.this.notifyAll();
 			}
 		}
@@ -116,7 +118,7 @@
 		raw_stderr = new FileInputStream(stderr_fd);
 
 		// now signal child to proceed
-		FileOutputStream sync = new FileOutputStream(sync_fd);
+		sync = new FileOutputStream(sync_fd);
 		byte[] sbuf = new byte[1];
 		try {
 			sync.write(sbuf);
@@ -164,6 +166,7 @@
 		raw_stdout.close();
 		raw_stderr.close();
 		stdin_stream.close();
+		sync.close();
 	}
 	catch (IOException e) {
 		e.printStackTrace();
@@ -184,6 +187,31 @@
 private native int execWait();
 private native static void sendSignal0(int pid, int signum);
 private native static int getKillSignal();
+
+protected void finalize() throws Throwable {
+	super.finalize();
+	try_close(raw_stdout);
+	try_close(raw_stderr);
+	try_close(stdin_stream);
+}
+
+private static void try_close(InputStream stream) {
+	if (stream != null) {
+		try {
+			stream.close();
+		}
+		catch (IOException e) {}
+	}
+}
+
+private static void try_close(OutputStream stream) {
+	if (stream != null) {
+		try {
+			stream.close();
+		}
+		catch (IOException e) {}
+	}
+}
 
 }
 




More information about the kaffe mailing list