Check to see whether there is a stdin, if not then the thread just exits.
(FELIX-729)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@719731 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/shell.tui/src/main/java/org/apache/felix/shell/tui/Activator.java b/shell.tui/src/main/java/org/apache/felix/shell/tui/Activator.java
index 9848d05..b964a2e 100644
--- a/shell.tui/src/main/java/org/apache/felix/shell/tui/Activator.java
+++ b/shell.tui/src/main/java/org/apache/felix/shell/tui/Activator.java
@@ -110,17 +110,16 @@
if (m_runnable != null)
{
m_runnable.stop();
- m_thread.interrupt();
}
}
private class ShellTuiRunnable implements Runnable
{
- private volatile boolean stop = false;
+ private volatile boolean m_stop = false;
public void stop()
{
- stop = true;
+ m_stop = true;
}
public void run()
@@ -128,7 +127,17 @@
String line = null;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
- while (!stop)
+ // Check to see if we have stdin.
+ try
+ {
+ System.in.available();
+ }
+ catch (IOException ex)
+ {
+ m_stop = true;
+ }
+
+ while (!m_stop)
{
System.out.print("-> ");
@@ -176,4 +185,4 @@
}
}
}
-}
\ No newline at end of file
+}