diff --git a/src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.java b/src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.java index cf194a2f1932b26436a1841ba06bd0c39e95bd35..bdec8fc54ed4e02c13f44f299bad0d4770ca2cda 100644 --- a/src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.java +++ b/src/solaris/classes/sun/tools/attach/LinuxVirtualMachine.java @@ -37,6 +37,8 @@ import java.util.Properties; * Linux implementation of HotSpotVirtualMachine */ public class LinuxVirtualMachine extends HotSpotVirtualMachine { + // temp directory for socket file + private static final String tmpdir = System.getProperty("java.io.tmpdir"); // Indicates if this machine uses the old LinuxThreads static boolean isLinuxThreads; @@ -260,7 +262,7 @@ public class LinuxVirtualMachine extends HotSpotVirtualMachine { // Return the socket file for the given process. // Checks working directory of process for .java_pid. If not - // found it looks in /tmp. + // found it looks in temp directory. private String findSocketFile(int pid) { // First check for a .java_pid file in the working directory // of the target process @@ -268,20 +270,17 @@ public class LinuxVirtualMachine extends HotSpotVirtualMachine { String path = "/proc/" + pid + "/cwd/" + fn; File f = new File(path); if (!f.exists()) { - // Not found, so try /tmp - path = "/tmp/" + fn; - f = new File(path); - if (!f.exists()) { - return null; // not found - } + // Not found, so try temp directory + f = new File(tmpdir, fn); + path = f.exists() ? f.getPath() : null; } return path; } // On Solaris/Linux a simple handshake is used to start the attach mechanism // if not already started. The client creates a .attach_pid file in the - // target VM's working directory (or /tmp), and the SIGQUIT handler checks - // for the file. + // target VM's working directory (or temp directory), and the SIGQUIT handler + // checks for the file. private File createAttachFile(int pid) throws IOException { String fn = ".attach_pid" + pid; String path = "/proc/" + pid + "/cwd/" + fn; @@ -289,8 +288,7 @@ public class LinuxVirtualMachine extends HotSpotVirtualMachine { try { f.createNewFile(); } catch (IOException x) { - path = "/tmp/" + fn; - f = new File(path); + f = new File(tmpdir, fn); f.createNewFile(); } return f; diff --git a/src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.java b/src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.java index ed923639bae64f9f1c5081af620c97a16e8a9f84..0d6b234fa14ced579e3a36437578947d7387e773 100644 --- a/src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.java +++ b/src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.java @@ -38,6 +38,11 @@ import java.util.Properties; * Solaris implementation of HotSpotVirtualMachine. */ public class SolarisVirtualMachine extends HotSpotVirtualMachine { + // Use /tmp instead of /var/tmp on Solaris as /tmp is the default used by + // HotSpot when the property is not set on the command line. + private static final String tmpdir1 = System.getProperty("java.io.tmpdir"); + private static final String tmpdir = + (tmpdir1.equals("/var/tmp") || tmpdir1.equals("/var/tmp/")) ? "/tmp" : tmpdir1; // door descriptor; private int fd = -1; @@ -187,7 +192,7 @@ public class SolarisVirtualMachine extends HotSpotVirtualMachine { } // The door is attached to .java_pid in the target VM's working - // directory or /tmp. + // directory or temporary directory. private int openDoor(int pid) throws IOException { // First check for a .java_pid file in the working directory // of the target process @@ -196,7 +201,7 @@ public class SolarisVirtualMachine extends HotSpotVirtualMachine { try { fd = open(path); } catch (FileNotFoundException fnf) { - path = "/tmp/" + fn; + path = tmpdir + "/" + fn; fd = open(path); } @@ -213,8 +218,8 @@ public class SolarisVirtualMachine extends HotSpotVirtualMachine { // On Solaris/Linux a simple handshake is used to start the attach mechanism // if not already started. The client creates a .attach_pid file in the - // target VM's working directory (or /tmp), and the SIGQUIT handler checks - // for the file. + // target VM's working directory (or temporary directory), and the SIGQUIT + // handler checks for the file. private File createAttachFile(int pid) throws IOException { String fn = ".attach_pid" + pid; String path = "/proc/" + pid + "/cwd/" + fn; @@ -222,8 +227,7 @@ public class SolarisVirtualMachine extends HotSpotVirtualMachine { try { f.createNewFile(); } catch (IOException x) { - path = "/tmp/" + fn; - f = new File(path); + f = new File(tmpdir, fn); f.createNewFile(); } return f;