Suppose this:
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(SU);
DataOutputStream processStream = new DataOutputStream(process.getOutputStream());
processStream.writeChars("cat /qwerty");
processStream.writeChars(EXIT);
processStream.flush();
int status = process.waitFor();
Log.d("EXIT STATUS", String.valueOf(status));
process.waitFor(); causes current thread to wait forever. I guess the problem is with that invalid command(I made that deliberately). But how do I handle such situations?
Busybox 1.17.1
When you send commands using the writeChars, they are all going on the same line in the shell and never being actually executed I think. You need to put newlines in to make the shell execute. Try this: