Runtime.getRuntime exec
<p>I have created a class to handle root commands in an android app, which is working just fine mostly. I create the process with Runtime.getRuntime().exec("su") and then enter commands using DataOutputStream and get the data from the commands using DataInputStream and the deprecated readLine. (I have tried using BufferedReader instead, but no difference to the issue).</p>

<p>My problem is that the app will hang if the command produces an error. F.eks. if I execute the command "[ -f /test ] &amp;&amp; md5sum /test" || echo 0" I will have no problems. However, if I execute "md5sum /test" and the file does not exist, I will have to force-close the app as it will get nowhere. In this example the solution is of cause just to check for the file like in the first example, but not every situation is this simple. Issues can happen, and when they do, people should not have to force-close applications.</p>

<p>Is there a way to fix this issue?</p>
