title: Running a shell utility from my app causes it to use 100% CPU
body: <p>This is sort of an odd one:</p>
  
  <p>I am trying to run a terminal command from my android app. The command launches a small linux utility that runs in the background. When I launch it from a terminal emulator it works fine, with no unusual CPU activity, but when I run the same command from my app, the utility that it launches uses a ton of CPU. Also, another process (system/bin/logcat2) shows up and starts using a bunch of CPU as well.</p>
  
  <p>Here is the code I am using to issue the shell commands:</p>
  
  <pre><code> void execCommandLine(String command)
      {
          Runtime runtime = Runtime.getRuntime();
          Process proc = null;
          OutputStreamWriter osw = null;
  
          try
          {
              proc = runtime.exec("su");
              osw = new OutputStreamWriter(proc.getOutputStream());
              osw.write(command);
              osw.flush();
              osw.close();
          }
          catch (IOException ex)
          {
  
              Log.e("execCommandLine()", "Command resulted in an IO Exception: " + command);
              return;
          }
          finally
          {
              if (osw != null)
              {
                  try
                  {
                      osw.close();
                  }
                  catch (IOException e){}
              }
          }
  
          try 
          {
              proc.waitFor();
          }
          catch (InterruptedException e){}
  
          if (proc.exitValue() != 0)
          {
  
              Log.e("execCommandLine()", "Command returned error: " + command + "\n  Exit code: " + proc.exitValue());
          }
      }
  </code></pre>
  
  <p>Anyone know what's going on?</p>