diff options
author | Sven Gothel <[email protected]> | 2015-09-23 06:42:28 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-09-23 06:42:28 +0200 |
commit | be9614d73e69159fbba5b458a4450b5df3a6613b (patch) | |
tree | 769fd32294c7dca847c361b317a99a8ccec24201 | |
parent | 0f08d051974d840ca898d7d0b888a679e4dee248 (diff) |
Bug 1219: IOUtil.testDirExe: Issue Process.destroy() in finalize block to ensure launched native exe process terminates.
See Bug 1219 comment 58: It seems that on some Windows platforms
the launched native process using our test-exe keeps running
even though we issued Process.waitFor().
Hence we issue Process.destroy() in the finalize block
to at least attempt to terminate it.
Note: The Process implementation is platform specific and may vary.
-rwxr-xr-x | make/scripts/java-win64.bat | 2 | ||||
-rw-r--r-- | src/java/com/jogamp/common/util/IOUtil.java | 16 |
2 files changed, 15 insertions, 3 deletions
diff --git a/make/scripts/java-win64.bat b/make/scripts/java-win64.bat index fb60ced..03a77f5 100755 --- a/make/scripts/java-win64.bat +++ b/make/scripts/java-win64.bat @@ -18,7 +18,7 @@ echo CP_ALL %CP_ALL% set X_ARGS="-Drootrel.build=%BLD_SUB%" "-Dgluegen.root=.."
REM set D_ARGS="-Djogamp.debug.IOUtil" "-Djogamp.debug.JNILibLoader" "-Djogamp.debug.TempFileCache" "-Djogamp.debug.JarUtil" "-Djogamp.debug.TempJarCache"
REM set D_ARGS="-Djogamp.debug.Platform" "-Djogamp.debug.NativeLibrary" "-Djogamp.debug.IOUtil"
-set D_ARGS="-Djogamp.debug.IOUtil" "-Djogamp.debug.IOUtil.Exe"
+set D_ARGS="-Djogamp.debug.IOUtil" "-Djogamp.debug.IOUtil.Exe" "-Djogamp.debug.IOUtil.Exe.NoStream"
REM set D_ARGS="-Djogamp.debug=all"
REM %J2RE_HOME%\bin\java -classpath %CP_ALL% %X_ARGS% %D_ARGS% "-Djava.library.path=%LIB_DIR%" "-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" %1 %2 %3 %4 %5 %6 %7 %8 %9 > java-win64.log 2>&1
diff --git a/src/java/com/jogamp/common/util/IOUtil.java b/src/java/com/jogamp/common/util/IOUtil.java index 59b0c9d..26e1f74 100644 --- a/src/java/com/jogamp/common/util/IOUtil.java +++ b/src/java/com/jogamp/common/util/IOUtil.java @@ -941,6 +941,7 @@ public class IOUtil { int res = -1; int exitValue = -1; if( existingExe || exeTestFile.setExecutable(true /* exec */, true /* ownerOnly */) ) { + Process pr = null; try { if( !existingExe ) { fillExeTestFile(exeTestFile); @@ -948,11 +949,11 @@ public class IOUtil { // Using 'Process.exec(String[])' avoids StringTokenizer of 'Process.exec(String)' // and hence splitting up command by spaces! // Note: All no-exec cases throw an IOExceptions at ProcessBuilder.start(), i.e. below exec() call! - final Process pr = Runtime.getRuntime().exec( getExeTestCommandArgs( exeTestFile.getCanonicalPath() ), null, null ); + pr = Runtime.getRuntime().exec( getExeTestCommandArgs( exeTestFile.getCanonicalPath() ), null, null ); if( DEBUG_EXE && !DEBUG_EXE_NOSTREAM ) { new StreamMonitor(new InputStream[] { pr.getInputStream(), pr.getErrorStream() }, System.err, "Exe-Tst: "); } - pr.waitFor() ; + pr.waitFor(); exitValue = pr.exitValue(); // Note: Bug 1219 Comment 50: On reporter's machine exit value 1 is being returned res = 0; // file has been executed } catch (final SecurityException se) { @@ -963,6 +964,17 @@ public class IOUtil { System.err.println("IOUtil.testDirExec: <"+exeTestFile.getAbsolutePath()+">: Caught "+t.getClass().getSimpleName()+": "+t.getMessage()); t.printStackTrace(); } + } finally { + if( null != pr ) { + // Bug 1219 Comment 58: Ensure that the launched process gets terminated! + // This is Process implementation specific and varies on different platforms, + // hence it may be required. + try { + pr.destroy(); + } catch (final Throwable t) { + ExceptionUtils.dumpThrowable("", t); + } + } } } final boolean ok = 0 == res; |