private int openDoor(int pid) throws IOException { String path = tmpdir + "/.java_pid" + pid;; fd = open(path); // Check that the file owner/permission to avoid attaching to // bogus process try { checkPermissions(path); } catch (IOException ioe) { close(fd); throw ioe; } return fd; }
@Override public synchronized int read(byte[] bs, int off, int len) throws IOException { if ((off < 0) || (off > bs.length) || (len < 0) || ((off + len) > bs.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) return 0; return SolarisVirtualMachine.read(s, bs, off, len); }
private static VirtualMachine getVirtualMachineImplementationFromEmbeddedOnes(String pid) { try { if (isWindows()) { return new WindowsVirtualMachine(ATTACH_PROVIDER, pid); } String osName = System.getProperty("os.name"); if (osName.startsWith("Linux") || osName.startsWith("LINUX")) { return new LinuxVirtualMachine(ATTACH_PROVIDER, pid); } else if (osName.startsWith("Mac OS X")) { return new BsdVirtualMachine(ATTACH_PROVIDER, pid); } else if (osName.startsWith("Solaris")) { return new SolarisVirtualMachine(ATTACH_PROVIDER, pid); } } catch (AttachNotSupportedException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } catch (UnsatisfiedLinkError e) { throw new IllegalStateException("Native library for Attach API not available in this JRE", e); } return null; }
fd = openDoor(pid); } catch (FileNotFoundException fnf1) { File f = createAttachFile(pid); try { sigquit(pid); int retries = (int)(attachTimeout() / delay); do { try { } catch (InterruptedException x) { } try { fd = openDoor(pid); } catch (FileNotFoundException fnf2) { } i++;
/** * Detach from the target VM */ @Override public void detach() throws IOException { synchronized (this) { if (fd != -1) { close(fd); fd = -1; } } }
private static VirtualMachine getVirtualMachineImplementationFromEmbeddedOnes(String pid) { try { if (isWindows()) { return new WindowsVirtualMachine(ATTACH_PROVIDER, pid); } String osName = System.getProperty("os.name"); if (osName.startsWith("Linux") || osName.startsWith("LINUX")) { return new LinuxVirtualMachine(ATTACH_PROVIDER, pid); } else if (osName.startsWith("Mac OS X")) { return new BsdVirtualMachine(ATTACH_PROVIDER, pid); } else if (osName.startsWith("Solaris")) { return new SolarisVirtualMachine(ATTACH_PROVIDER, pid); } } catch (AttachNotSupportedException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } catch (UnsatisfiedLinkError e) { throw new IllegalStateException("Native library for Attach API not available in this JRE", e); } return null; }
@Override public void close() throws IOException { SolarisVirtualMachine.close(s); } }
private static VirtualMachine getVirtualMachineImplementationFromEmbeddedOnes(String pid) { try { if (isWindows()) { return new WindowsVirtualMachine(ATTACH_PROVIDER, pid); } String osName = System.getProperty("os.name"); if (osName.startsWith("Linux") || osName.startsWith("LINUX")) { return new LinuxVirtualMachine(ATTACH_PROVIDER, pid); } else if (osName.startsWith("Mac OS X")) { return new BsdVirtualMachine(ATTACH_PROVIDER, pid); } else if (osName.startsWith("Solaris")) { return new SolarisVirtualMachine(ATTACH_PROVIDER, pid); } } catch (AttachNotSupportedException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } catch (UnsatisfiedLinkError e) { throw new IllegalStateException("Native library for Attach API not available in this JRE", e); } return null; }