Spawn.vala
[gitlive] / Spawn.vala
index 070280d..0bacafe 100644 (file)
@@ -224,14 +224,14 @@ public class Spawn : Object
          
         if (this.cfg.debug) {
             
-            stdout.print("PID: %d" ,this.pid);
+            stdout.printf("PID: %d" ,this.pid);
         }
          
         ChildWatch.add (this.pid, (w_pid, result) => {
            
             this.result = result;
-            if (_this.debug) {
-                print("child_watch_add : result:%d ", result);
+            if (this.cfg.debug) {
+                stdout.printf("child_watch_add : result:%d ", result);
             }
            
             this.read(this.out_ch);
@@ -378,8 +378,8 @@ public class Spawn : Object
         
         //print("write_char retunred:" + JSON.stringify(res) +  ' ' +JSON.stringify(ret)  );
         
-            if (res != GLib.IOStatus.NORMAL) {
-                throw "Write failed";
+        if (res != GLib.IOStatus.NORMAL) {
+            throw "Write failed";
         }
         //return ret.value;
         return str.length;
@@ -396,13 +396,19 @@ public class Spawn : Object
         string prop = (ch == this.out_ch) ? "output" : "stderr";
        // print("prop: " + prop);
         var _this = this;
+        string str_return;
         
-       
         //print(JSON.stringify(ch, null,4));
         while (true) {
-            var x =   {};
-            var status = ch.read_line( x);
+            var buffer = new StringBuilder("");
+            
+            try {
+                var status = ch.read_line( buffer,  term_pos );
+            } catch (Error e) {
+                //FIXme
+                break; // ??
+                
+            }
             // print('status: '  +JSON.stringify(status));
             // print(JSON.stringify(x));
              switch(status) {