title: java.io.IOException: error=11
body: <p>I am experiencing a weird problem with the Java <code>ProcessBuilder</code>. The code is shown below (in a slightly simplified form)</p>
  
  <pre><code>public class Whatever implements Runnable
  {
  
  public void run(){
          //someIdentifier is a randomly generated string
          String in = someIdentifier + "input.txt";
          String out = someIdentifier + "output.txt";
          ProcessBuilder builder = new ProcessBuilder("./whateveer.sh", in, out);
          try {
              Process process = builder.start();
              process.waitFor();
          } catch (IOException e) {
              log.error("Could not launch process. Command: " + builder.command(), e);
          } catch (InterruptedException ex) {
              log.error(ex);
          }
  }
  
  }
  </code></pre>
  
  <p>whatever.sh reads:</p>
  
  <pre><code>R --slave --args $1 $2 &lt;whatever1.R &gt;&gt; r.log    
  </code></pre>
  
  <p>Loads of instances of <code>Whatever</code> are submitted to an <code>ExecutorService</code> of fixed size (35). The rest of the application waits for all of them to finish- implemented with a <code>CountdownLatch</code>. Everything runs fine for several hours (Scientific Linux 5.0, java version "1.6.0_24") before throwing the following exception:</p>
  
  <pre><code>java.io.IOException: Cannot run program "./whatever.sh": java.io.IOException: error=11, Resource temporarily unavailable
      at java.lang.ProcessBuilder.start(Unknown Source)
  ... rest of stack trace omitted...
  </code></pre>
  
  <p>Does anyone have an idea what this means? Based on the google/bing search results for <code>java.io.IOException: error=11</code>, it is not the most common of exceptions and I am completely baffled.</p>
  
  <p>My wild and not so educated guess is that I have too many threads trying to launch the same file at the same time. However, it takes hours of CPU time to reproduce the problem, so I have not tried with a smaller number. </p>
  
  <p>Any suggestions are greatly appreciated.</p>