Some more infrastructure. Maybe other things.
[tripe-android] / sys.scala
index 402bf1d..c449414 100644 (file)
--- a/sys.scala
+++ b/sys.scala
@@ -38,6 +38,8 @@ import java.nio.{ByteBuffer, CharBuffer};
 import java.nio.charset.Charset;
 import java.util.Date;
 
+import Implicits.truish;
+
 /*----- Some magic for C strings ------------------------------------------*/
 
 type CString = Array[Byte];
@@ -773,8 +775,9 @@ def runCommand(cmd: String*): (String, String) = {
   withCleaner { clean =>
 
     /* Create the child process and pick up the ends of its streams. */
-    val pb = new ProcessBuilder(cmd.asJava).redirectInput(devnull);
+    val pb = new ProcessBuilder(cmd.asJava);
     val kid = pb.start(); clean { kid.destroy(); }
+    kid.getOutputStream.close();
     val out = kid.getInputStream(); clean { out.close(); }
     val err = kid.getErrorStream(); clean { err.close(); }
 
@@ -796,7 +799,7 @@ def runCommand(cmd: String*): (String, String) = {
 
     /* Check the exit status. */
     val rc = kid.exitValue;
-    if (rc != 0) throw new SubprocessFailed(cmd, rc, berr.result);
+    if (rc) throw new SubprocessFailed(cmd, rc, berr.result);
 
     /* We're all done. */
     return (bout.result, berr.result);
@@ -817,7 +820,7 @@ private var triggers: List[Wrapper] = Nil;
 
 private def getTrigger(): Wrapper = {
   triggerLock synchronized {
-    if (nTriggers == 0)
+    if (!nTriggers)
       make_trigger()
     else {
       val trig = triggers.head;