title: Read superuser process output in Android
body: <p>I'm trying to run a shell command using superuser (su) periodically in the following way:</p>
  
  <p>first I get the su process:</p>
  
  <pre><code>Process p = Runtime.getRuntime().exec("su");
  </code></pre>
  
  <p>then, periodically I run:</p>
  
  <pre><code>p.getOutputStream().write("some shell command".getBytes());
  BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
  String line;
  while ((line = r.readLine()) != null) //Process output line
  </code></pre>
  
  <p>this problem is that the r.readLine() blocks and does not return never. only if I create a new  su process and add p.getOutputStream().close() before reading output the code succeeds.</p>
  
  <p>is there a way to use a single su process for issuing shell commands?</p>