Skip to content
This repository
Browse code

wait flag

  • Loading branch information...
commit 38ccb86488e8eefbb27068e4e3094eebec1f8039 1 parent dc0ee98
JP Moresmau authored January 13, 2012
8  net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/scion/ScionManager.java
@@ -187,8 +187,8 @@ public void run() {
187 187
     boolean doBrowserSetup=true;
188 188
     boolean ignore=HaskellUIPlugin.getDefault().getPreferenceStore().getBoolean( IPreferenceConstants.IGNORE_TOOOLD_EXECUTABLE );
189 189
     if (!ignore){
190  
-      final boolean buildwrapperVersionOK=serverExecutablePath==null || checkVersion( serverExecutablePath, MINIMUM_BUILDWRAPPER );
191  
-      final boolean browserVersionOK=browserExecutablePath==null || checkVersion( browserExecutablePath, MINIMUM_SCIONBROWSER );
  190
+      final boolean buildwrapperVersionOK=serverExecutablePath==null || checkVersion( serverExecutablePath, MINIMUM_BUILDWRAPPER ,true);
  191
+      final boolean browserVersionOK=browserExecutablePath==null || checkVersion( browserExecutablePath, MINIMUM_SCIONBROWSER,false );
192 192
 
193 193
       doBuildWrapperSetup=buildwrapperVersionOK; // do not launch if too old
194 194
       doBrowserSetup=browserVersionOK;// do not launch if too old
@@ -427,10 +427,10 @@ private synchronized void serverFactorySetup(){
427 427
 //    }
428 428
   }
429 429
 
430  
-  public static boolean checkVersion(final IPath path,final String minimal){
  430
+  public static boolean checkVersion(final IPath path,final String minimal,final boolean wait){
431 431
     if (path!=null){
432 432
       try {
433  
-        String currentVersion=ProcessRunner.getExecutableVersion(path.toOSString());
  433
+        String currentVersion=ProcessRunner.getExecutableVersion(path.toOSString(),wait);
434 434
         if (currentVersion==null){
435 435
           return false;
436 436
         }
26  net.sf.eclipsefp.haskell.util/src/net/sf/eclipsefp/haskell/util/ProcessRunner.java
@@ -75,23 +75,31 @@ private static Thread redirect( final Reader in, final Writer out, String name )
75 75
 	  return new Thread[]{t1,t2};
76 76
   }
77 77
 
78  
-  public static String getExecutableVersion(String path) throws IOException{
  78
+  public static String getExecutableVersion(String path,boolean wait) throws IOException{
79 79
 	  File f=new File(path);
80 80
 	  if (f.exists()){
81 81
 		  StringWriter sw=new StringWriter();
82 82
 		  Process p=new ProcessRunner().executeNonblocking(f.getParentFile(), sw, null, f.getAbsolutePath(),"--version");
83  
-		  for (int a=0;a<50;a++){ // 50 * 100 -> 5 seconds maxi
  83
+		  if (wait){
84 84
 			  try {
85  
-				  p.exitValue();
86  
-				  break;
87  
-			  } catch (IllegalThreadStateException ise){
88  
-				  // still running
89  
-			  }
90  
-			  try {
91  
-				  Thread.sleep(100);
  85
+				  p.waitFor();
92 86
 			  } catch (InterruptedException ie){
93 87
 				  //
94 88
 			  }
  89
+		  } else {
  90
+			  for (int a=0;a<50;a++){ // 50 * 100 -> 5 seconds maxi
  91
+				  try {
  92
+					  p.exitValue();
  93
+					  break;
  94
+				  } catch (IllegalThreadStateException ise){
  95
+					  // still running
  96
+				  }
  97
+				  try {
  98
+					  Thread.sleep(100);
  99
+				  } catch (InterruptedException ie){
  100
+					  //
  101
+				  }
  102
+			  }
95 103
 		  }
96 104
 		  try {
97 105
 			  String line=sw.toString().trim();

0 notes on commit 38ccb86

Please sign in to comment.
Something went wrong with that request. Please try again.