ADDITIONAL SYSTEM INFORMATION :
x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The test below demonstrates a problem.
% cat Test.java
import java.io.IOException;
public class Test {
public static void main(final String[] args) {
if (args.length == 0) {
System.out.println("Run:\n java Test `uname -n` &");
return;
}
try {
String cmd = "/usr/bin/ssh 12345@" + args[0] + " uname -a";
System.out.println("\ncmd: " + cmd);
Runtime.getRuntime().exec(cmd);
} catch (IOException ex) {
System.out.println(" IOException");
}
for (int i = 0; i < 20; i++) {
System.out.println(" i= " + i);
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
System.out.println(" InterruptedException");
}
}
}
}
In line 11, I use a non-existent username '12345' to ssh on the same host.
In this case, ssh asks a password from TTY and this is a problem.
All threads are hanging when ssh asks a password.
I run on Linux:
% uname -m -o
x86_64 GNU/Linux
% javac Test.java
% java Test `uname -n` & ### <---- use "&" to run the process in the background.
[1] 1905366
cmd: /usr/bin/ssh 12345@..... uname -a
i= 0
i= 1
i= 2
% jstack -F 1905366
Attaching to process ID 1905366, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.291-b10
Deadlock Detection:
No deadlocks found.
Thread 1905446: (state = IN_NATIVE)
- java.lang.UNIXProcess.waitForProcessExit(int) @bci=0 (Interpreted frame)
- java.lang.UNIXProcess.lambda$initStreams$3() @bci=5, line=289 (Interpreted frame)
- java.lang.UNIXProcess$$Lambda$7.run() @bci=4 (Interpreted frame)
- java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) @bci=95, line=1149 (Interpreted frame)
- java.util.concurrent.ThreadPoolExecutor$Worker.run() @bci=5, line=624 (Interpreted frame)
- java.lang.Thread.run() @bci=11, line=748 (Interpreted frame)
Thread 1905424: (state = BLOCKED)
Thread 1905423: (state = BLOCKED)
- java.lang.Object.wait(long) @bci=0 (Interpreted frame)
- java.lang.ref.ReferenceQueue.remove(long) @bci=59, line=144 (Interpreted frame)
- java.lang.ref.ReferenceQueue.remove() @bci=2, line=165 (Interpreted frame)
- java.lang.ref.Finalizer$FinalizerThread.run() @bci=36, line=216 (Interpreted frame)
Thread 1905422: (state = BLOCKED)
- java.lang.Object.wait(long) @bci=0 (Interpreted frame)
- java.lang.Object.wait() @bci=2, line=502 (Interpreted frame)
- java.lang.ref.Reference.tryHandlePending(boolean) @bci=54, line=191 (Interpreted frame)
- java.lang.ref.Reference$ReferenceHandler.run() @bci=1, line=153 (Interpreted frame)
Thread 1905372: (state = BLOCKED)
- java.lang.Thread.sleep(long) @bci=0 (Interpreted frame)
- Test.main(java.lang.String[]) @bci=122, line=21 (Interpreted frame)
We need API to support pseudoterminal.
x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The test below demonstrates a problem.
% cat Test.java
import java.io.IOException;
public class Test {
public static void main(final String[] args) {
if (args.length == 0) {
System.out.println("Run:\n java Test `uname -n` &");
return;
}
try {
String cmd = "/usr/bin/ssh 12345@" + args[0] + " uname -a";
System.out.println("\ncmd: " + cmd);
Runtime.getRuntime().exec(cmd);
} catch (IOException ex) {
System.out.println(" IOException");
}
for (int i = 0; i < 20; i++) {
System.out.println(" i= " + i);
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
System.out.println(" InterruptedException");
}
}
}
}
In line 11, I use a non-existent username '12345' to ssh on the same host.
In this case, ssh asks a password from TTY and this is a problem.
All threads are hanging when ssh asks a password.
I run on Linux:
% uname -m -o
x86_64 GNU/Linux
% javac Test.java
% java Test `uname -n` & ### <---- use "&" to run the process in the background.
[1] 1905366
cmd: /usr/bin/ssh 12345@..... uname -a
i= 0
i= 1
i= 2
% jstack -F 1905366
Attaching to process ID 1905366, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.291-b10
Deadlock Detection:
No deadlocks found.
Thread 1905446: (state = IN_NATIVE)
- java.lang.UNIXProcess.waitForProcessExit(int) @bci=0 (Interpreted frame)
- java.lang.UNIXProcess.lambda$initStreams$3() @bci=5, line=289 (Interpreted frame)
- java.lang.UNIXProcess$$Lambda$7.run() @bci=4 (Interpreted frame)
- java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) @bci=95, line=1149 (Interpreted frame)
- java.util.concurrent.ThreadPoolExecutor$Worker.run() @bci=5, line=624 (Interpreted frame)
- java.lang.Thread.run() @bci=11, line=748 (Interpreted frame)
Thread 1905424: (state = BLOCKED)
Thread 1905423: (state = BLOCKED)
- java.lang.Object.wait(long) @bci=0 (Interpreted frame)
- java.lang.ref.ReferenceQueue.remove(long) @bci=59, line=144 (Interpreted frame)
- java.lang.ref.ReferenceQueue.remove() @bci=2, line=165 (Interpreted frame)
- java.lang.ref.Finalizer$FinalizerThread.run() @bci=36, line=216 (Interpreted frame)
Thread 1905422: (state = BLOCKED)
- java.lang.Object.wait(long) @bci=0 (Interpreted frame)
- java.lang.Object.wait() @bci=2, line=502 (Interpreted frame)
- java.lang.ref.Reference.tryHandlePending(boolean) @bci=54, line=191 (Interpreted frame)
- java.lang.ref.Reference$ReferenceHandler.run() @bci=1, line=153 (Interpreted frame)
Thread 1905372: (state = BLOCKED)
- java.lang.Thread.sleep(long) @bci=0 (Interpreted frame)
- Test.main(java.lang.String[]) @bci=122, line=21 (Interpreted frame)
We need API to support pseudoterminal.