< prev index next >

src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java

Print this page




 195         }
 196 
 197         public synchronized int read(byte[] bs, int off, int len) throws IOException {
 198             if ((off < 0) || (off > bs.length) || (len < 0) ||
 199                 ((off + len) > bs.length) || ((off + len) < 0)) {
 200                 throw new IndexOutOfBoundsException();
 201             } else if (len == 0)
 202                 return 0;
 203 
 204             return VirtualMachineImpl.read(s, bs, off, len);
 205         }
 206 
 207         public void close() throws IOException {
 208             VirtualMachineImpl.close(s);
 209         }
 210     }
 211 
 212     // The door is attached to .java_pid<pid> in the temporary directory.
 213     private int openDoor(int pid) throws IOException {
 214         socket_path = tmpdir + "/.java_pid" + pid;

 215         fd = open(socket_path);









 216 
 217         // Check that the file owner/permission to avoid attaching to
 218         // bogus process
 219         try {
 220             checkPermissions(socket_path);
 221         } catch (IOException ioe) {
 222             close(fd);
 223             throw ioe;
 224         }
 225         return fd;
 226     }
 227 
 228     // On Solaris a simple handshake is used to start the attach mechanism
 229     // if not already started. The client creates a .attach_pid<pid> file in the
 230     // target VM's working directory (or temporary directory), and the SIGQUIT
 231     // handler checks for the file.
 232     private File createAttachFile(int pid) throws IOException {
 233         String fn = ".attach_pid" + pid;
 234         String path = "/proc/" + pid + "/cwd/" + fn;
 235         File f = new File(path);




 195         }
 196 
 197         public synchronized int read(byte[] bs, int off, int len) throws IOException {
 198             if ((off < 0) || (off > bs.length) || (len < 0) ||
 199                 ((off + len) > bs.length) || ((off + len) < 0)) {
 200                 throw new IndexOutOfBoundsException();
 201             } else if (len == 0)
 202                 return 0;
 203 
 204             return VirtualMachineImpl.read(s, bs, off, len);
 205         }
 206 
 207         public void close() throws IOException {
 208             VirtualMachineImpl.close(s);
 209         }
 210     }
 211 
 212     // The door is attached to .java_pid<pid> in the temporary directory.
 213     private int openDoor(int pid) throws IOException {
 214         socket_path = tmpdir + "/.java_pid" + pid;
 215         try {
 216             fd = open(socket_path);
 217         } catch (IOException ioe) {
 218             // Retry the operation after a short pause
 219             try {
 220                 Thread.sleep(100);
 221                 fd = open(socket_path);
 222             } catch (InterruptedException ie) {
 223                 // ignored
 224             }
 225         }
 226 
 227         // Check that the file owner/permission to avoid attaching to
 228         // bogus process
 229         try {
 230             checkPermissions(socket_path);
 231         } catch (IOException ioe) {
 232             close(fd);
 233             throw ioe;
 234         }
 235         return fd;
 236     }
 237 
 238     // On Solaris a simple handshake is used to start the attach mechanism
 239     // if not already started. The client creates a .attach_pid<pid> file in the
 240     // target VM's working directory (or temporary directory), and the SIGQUIT
 241     // handler checks for the file.
 242     private File createAttachFile(int pid) throws IOException {
 243         String fn = ".attach_pid" + pid;
 244         String path = "/proc/" + pid + "/cwd/" + fn;
 245         File f = new File(path);


< prev index next >