Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your app is likely hanging because you probably aren't processing stderr/stdout generated by the spawned process. The reason behind this is that spawned processes have very small output buffers (usually only a few kilobytes). Once those buffers are full, that process will hang until its buffers free up enough space for it to continue writing output text. I suspect you're having problems when running that second command because that second command is failing and generating lots of console output. Your child process runs out of buffer space and then tries to block until more space becomes available, which never happens.</p> <p><code>Runtime.getRuntime().exec()</code> returns an instance of <code>Process</code>. <code>Process</code> objects have an accessor method (I believe it's <code>getInputStream()</code>) that allow you to consume its stdout. You also need to do the same with <code>getErrorStream()</code>. Typically, I get the <code>InputStream</code>, then have a separate thread continually consume data from that <code>InputStream</code> until it's closed. You don't need to do anything with the data per se, just read it. This will tell the underlying process that it can clear its output buffers, hopefully before they ever become full (thus, causing the Process to block).</p> <p>Also, I'm not 100% familiar with Android, but in plain ol' java, it's better to use <code>ProcessBuilder</code> to spawn child <code>Process</code> instances. This is because <code>ProcessBuilder</code> lets you combine the child's stderr AND stdout in the same stream, which lets you consume both within a single thread by just reading data from the stream returned by <code>process.getInputStream()</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload