diff --git a/src/java/org/lwjgl/LWJGLUtil.java b/src/java/org/lwjgl/LWJGLUtil.java index cac7f54a..b26e343e 100644 --- a/src/java/org/lwjgl/LWJGLUtil.java +++ b/src/java/org/lwjgl/LWJGLUtil.java @@ -380,6 +380,22 @@ public class LWJGLUtil { return paths; } + static void execPrivileged(final String[] cmd_array) throws Exception { + try { + Process process = (Process)AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + return Runtime.getRuntime().exec(cmd_array); + } + }); + // Close unused streams to make sure the child process won't hang + process.getInputStream().close(); + process.getOutputStream().close(); + process.getErrorStream().close(); + } catch (PrivilegedActionException e) { + throw (Exception)e.getCause(); + } + } + private static String getPrivilegedProperty(final String property_name) { return (String)AccessController.doPrivileged(new PrivilegedAction() { public Object run() { diff --git a/src/java/org/lwjgl/LinuxSysImplementation.java b/src/java/org/lwjgl/LinuxSysImplementation.java index d4e1c2c7..a813ceb2 100644 --- a/src/java/org/lwjgl/LinuxSysImplementation.java +++ b/src/java/org/lwjgl/LinuxSysImplementation.java @@ -32,8 +32,6 @@ package org.lwjgl; import java.security.AccessController; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; /** * @@ -50,19 +48,14 @@ class LinuxSysImplementation extends J2SESysImplementation { // Linux may as well resort to pure Java hackery, as there's no Linux native way of doing it // right anyway. - String[] browsers = {"firefox", "mozilla", "opera", "konqueror", "nautilus", "galeon", "netscape"}; + String[] browsers = {"xdg-open", "firefox", "mozilla", "opera", "konqueror", "nautilus", "galeon", "netscape"}; for (int i = 0; i < browsers.length; i ++) { final String browser = browsers[i]; try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { - Runtime.getRuntime().exec(new String[] { browser, url }); - return null; - } - }); + LWJGLUtil.execPrivileged(new String[] { browser, url }); return true; - } catch (PrivilegedActionException e) { + } catch (Exception e) { // Ignore e.printStackTrace(System.err); } diff --git a/src/java/org/lwjgl/WindowsSysImplementation.java b/src/java/org/lwjgl/WindowsSysImplementation.java index a3343c02..d9b1b66b 100644 --- a/src/java/org/lwjgl/WindowsSysImplementation.java +++ b/src/java/org/lwjgl/WindowsSysImplementation.java @@ -32,8 +32,6 @@ package org.lwjgl; import java.security.AccessController; -import java.security.PrivilegedExceptionAction; -import java.security.PrivilegedActionException; /** *
@@ -56,15 +54,10 @@ class WindowsSysImplementation extends DefaultSysImplementation { public boolean openURL(final String url) { try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { - Runtime.getRuntime().exec(new String[]{"rundll32", "url.dll,FileProtocolHandler", url}); - return null; - } - }); + LWJGLUtil.execPrivileged(new String[]{"rundll32", "url.dll,FileProtocolHandler", url}); return true; - } catch (PrivilegedActionException e) { - LWJGLUtil.log("Failed to open url (" + url + "): " + e.getCause().getMessage()); + } catch (Exception e) { + LWJGLUtil.log("Failed to open url (" + url + "): " + e.getMessage()); return false; } }