resources/RooUsage.txt
[app.Builder.js] / src / Spawn.vala
index a1aaa03..d3b9428 100644 (file)
@@ -71,6 +71,7 @@ public class Spawn : Object
        
        public bool is_async = true;
        public bool throw_exceptions = false;
+       public bool detach = false;
 
     public Spawn(string cwd, string[] args) throws Error
     {
@@ -139,7 +140,7 @@ public class Spawn : Object
      * result is applied to object properties (eg. '?' or 'stderr')
      * @returns {Object} self.
      */
-       public void run(SpawnFinish finish) throws SpawnError, GLib.SpawnError, GLib.IOChannelError
+       public void run( ) throws SpawnError, GLib.SpawnError, GLib.IOChannelError
        {
                
                 
@@ -153,11 +154,27 @@ public class Spawn : Object
                 
                GLib.debug("cd %s; %s" , this.cwd , string.joinv(" ", this.args));
                
-               
+               if (this.detach) { 
+                       Process.spawn_async_with_pipes (
+                               this.cwd,
+                               this.args,
+                               this.env.length > 0 ? this.env : null,
+                               SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD,
+                               null,
+                               out this.pid);
+                               ChildWatch.add (this.pid, (pid, status) => {
+                                       // Triggered when the child indicated by child_pid exits
+                                       Process.close_pid (pid);
+                                        
+                               });
+                               
+                               return;
+
+               }
                Process.spawn_async_with_pipes (
                                this.cwd,
                                this.args,
-                               this.env,
+                               this.env.length > 0 ? this.env : null,
                                SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD,
                                null,
                                out this.pid,
@@ -166,7 +183,7 @@ public class Spawn : Object
                                out standard_error);
 
                // stdout:
-
+                
                        
                //print(JSON.stringify(gret));    
                 
@@ -209,7 +226,7 @@ public class Spawn : Object
                        this.tidyup();
                        //print("DONE TIDYUP");
                        
-                       finish(this.result, this.output, this.stderr);
+                       this.complete(this.result, this.output, this.stderr);
                        
                });
            
@@ -354,7 +371,7 @@ public class Spawn : Object
      */
     private bool read(IOChannel ch) 
     {
-        string prop = (ch == this.out_ch) ? "output" : "stderr";
+       // string prop = (ch == this.out_ch) ? "output" : "stderr";
        // print("prop: " + prop);
 
         
@@ -388,10 +405,11 @@ public class Spawn : Object
                         
                     } else {
                         this.stderr += buffer;
+                        this.output_line(  buffer); 
                     }
                     //_this[prop] += x.str_return;
                     //if (this.cfg.debug) {
-                        GLib.debug("%s : %s", prop , buffer);
+                        //GLib.debug("%s : %s", prop , buffer);
                     //}
                     if (this.is_async) {