aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Henrique Barboza2011-12-26 13:03:18 (EST)
committerOtavio Pontes2011-12-27 06:41:50 (EST)
commitd94bf7de749e400a420d18aacdf2a96661d6e61a (patch)
tree19967f27804e5c261983aac305db86f034177d64
parente5af7404c983ec8350a3ac2ab15173b774457347 (diff)
downloadorg.eclipse.linuxtools-d94bf7de749e400a420d18aacdf2a96661d6e61a.zip
org.eclipse.linuxtools-d94bf7de749e400a420d18aacdf2a96661d6e61a.tar.gz
org.eclipse.linuxtools-d94bf7de749e400a420d18aacdf2a96661d6e61a.tar.bz2
Fixing bug #367505
Removed the p.waitFor() call which proved to be problematic on some cases.
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/perf/PerfCore.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/perf/PerfCore.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/perf/PerfCore.java
index c1e1bcd..f135bf5 100644
--- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/perf/PerfCore.java
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/perf/PerfCore.java
@@ -74,21 +74,22 @@ public class PerfCore {
BufferedReader input = null;
try {
// Alternatively can try with -i flag
- p = Runtime.getRuntime().exec("perf list"); //(char 1 as -t is a custom field seperator
- p.waitFor();
- input = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ p = Runtime.getRuntime().exec("perf list"); //(char 1 as -t is a custom field seperator
+
/*
* Old versions of Perf will send events list to stderr instead of stdout
* Checking if stdout is empty then read from stderr
*/
- if ( ! input.ready() )
- input = new BufferedReader(new InputStreamReader(p.getErrorStream()));
-
+ BufferedReader stdoutIn = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ BufferedReader stderrIn = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+
+ while (!stdoutIn.ready() && !stderrIn.ready()) continue;
+ input = stdoutIn.ready() ? stdoutIn : stderrIn;
+
} catch( IOException e ) {
e.printStackTrace();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
+
+ }
String line;
try {
while (( line = input.readLine()) != null){