--- old/src/jdk.attach/aix/classes/sun/tools/attach/VirtualMachineImpl.java 2016-08-11 19:44:15.370421794 +0300 +++ new/src/jdk.attach/aix/classes/sun/tools/attach/VirtualMachineImpl.java 2016-08-11 19:44:15.261421791 +0300 @@ -76,20 +76,28 @@ sendQuitTo(pid); // give the target VM time to start the attach mechanism - int i = 0; - long delay = 200; - int retries = (int)(attachTimeout() / delay); + final int delay_step = 100; + final long timeout = attachTimeout(); + long time_spend = 0; + long delay = 0; do { + // Increase timeout on each attempt to reduce polling + delay += delay_step; try { Thread.sleep(delay); } catch (InterruptedException x) { } path = findSocketFile(pid); - i++; - } while (i <= retries && path == null); + + time_spend += delay; + if (time_spend > timeout/2 && path == null) { + // Send QUIT again to give target VM the last chance to react + sendQuitTo(pid); + } + } while (time_spend <= timeout && path == null); if (path == null) { throw new AttachNotSupportedException( - "Unable to open socket file: target process not responding " + - "or HotSpot VM not loaded"); + String.format("Unable to open socket file %s: " + + "target process %d doesn't respond within %dms or HotSpot VM not loaded", f.getPath(), pid, time_spend)); } } finally { f.delete();