package org.tizen.emulator.manager.tool;
+import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
pb.directory(new File(FilePathResources.getBinPath()));
try {
- Process process = null;
- process = pb.start();
+ Process process = pb.start();
+ ProcessOutputReader.startRead(process, "check-hax");
process.waitFor();
exitValue = process.exitValue();
EMLogger.getLogger().log(Level.CONFIG, "check-hax's exit value : " + exitValue);
pb.directory(new File(FilePathResources.getBinPath()));
try {
- Process process = null;
- process = pb.start();
+ Process process = pb.start();
+ ProcessOutputReader.startRead(process, "check-gl");
process.waitFor();
exitValue = process.exitValue();
EMLogger.getLogger().log(Level.CONFIG, "'check-gl's exit value : " + exitValue);
public void close() {
dialog.close();
}
-}
\ No newline at end of file
+}
+
+class ProcessOutputReader extends Thread {
+
+ private BufferedReader reader;
+ private String processName;
+ private List<String> msgList = new ArrayList<String>();
+
+ public ProcessOutputReader(BufferedReader reader, String processName) {
+ this.reader = reader;
+ this.processName = processName;
+ this.setDaemon(true);
+ }
+
+ // Read output/error stream of process to prevent blocking due to full of buffer.
+ public static void startRead(Process process, String processName) {
+ BufferedReader out = new BufferedReader(new InputStreamReader(process.getInputStream()));
+ new ProcessOutputReader(out, processName).start();
+
+ BufferedReader err = new BufferedReader(new InputStreamReader(process.getErrorStream()));
+ new ProcessOutputReader(err, processName).start();
+ }
+
+ @Override
+ public void run(){
+ String msg;
+ try {
+ while ((msg = reader.readLine()) != null) {
+ msgList.add(msg);
+ }
+ } catch (IOException e) {
+ EMLogger.getLogger().warning(e.getMessage());
+ } finally {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ EMLogger.getLogger().warning(e.getMessage());
+ }
+ }
+
+ if (!msgList.isEmpty()) {
+ EMLogger.getLogger().info(processName + "'s stdout/stderr");
+ for (String s : msgList) {
+ EMLogger.getLogger().info(s);
+ }
+ msgList.clear();
+ }
+ }
+}