1 21 package org.apache.derbyTesting.functionTests.util; 22 23 import org.apache.derbyTesting.functionTests.harness.ProcessStreamResult; 24 import org.apache.derbyTesting.functionTests.harness.TimedProcess; 25 import java.util.Vector ; 26 import java.io.BufferedOutputStream ; 27 30 public class ExecProcUtil { 31 32 39 private static String timeoutMinutes = "2"; 40 41 44 private static int timeoutSecondsForProcess = 180; 45 46 54 public static void execCmdDumpResults(String [] args, Vector vCmd, 55 BufferedOutputStream bos) throws Exception { 56 ProcessStreamResult prout = null; 58 ProcessStreamResult prerr = null; 59 60 StringBuffer sb = new StringBuffer (); 61 62 for (int i = 0; i < args.length; i++) { 63 sb.append(args[i] + " "); 64 } 65 System.out.println(sb.toString()); 66 int totalSize = vCmd.size() + args.length; 67 String serverCmd[] = new String [totalSize]; 68 69 int i = 0; 70 for (i = 0; i < vCmd.size(); i++) 71 serverCmd[i] = (String ) vCmd.elementAt(i); 72 73 for (int j = 0; i < totalSize; i++) 74 serverCmd[i] = args[j++]; 75 76 System.out.flush(); 77 bos.flush(); 78 79 Process pr = Runtime.getRuntime().exec(serverCmd); 81 82 TimedProcess tp = new TimedProcess(pr); 85 prout = new ProcessStreamResult(pr.getInputStream(), bos, 86 timeoutMinutes); 87 prerr = new ProcessStreamResult(pr.getErrorStream(), bos, 88 timeoutMinutes); 89 90 boolean outTimedOut = prout.Wait(); 92 boolean errTimedOut = prerr.Wait(); 93 94 tp.waitFor(timeoutSecondsForProcess); 99 pr = null; 100 101 if (outTimedOut || errTimedOut) 102 System.out.println(" Reading from process streams timed out.. "); 103 104 System.out.flush(); 105 } 106 107 } 108 | Popular Tags |