:Revert "fix line numbering issues with vala generator - hopefully fixes completion...
[roobuilder] / src / Spawn.vala
index c80da5c..7b63163 100644 (file)
@@ -164,7 +164,7 @@ public class Spawn : Object
                        Process.spawn_async (   
                                this.cwd,
                                this.args,
-                               this.env.length > 0 ? this.env : null,
+                               this.env.length > 0 ? this.env : GLib.Environ.get (),
                                SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD,
                                null,
                                out pid);
@@ -234,8 +234,12 @@ public class Spawn : Object
                                this.ctx.quit();
                                this.ctx = null;
                        }
+                       // since it's closed - we might not need to remove the watches?
+                       
+                       this.err_src = -1;
+                       this.out_src = -1;
                        this.tidyup();
-                       //print("DONE TIDYUP");
+                       GLib.debug("DONE TIDYUP - calling complete");
                        
                        this.complete(this.result, this.output, this.stderr);
                        
@@ -319,6 +323,23 @@ public class Spawn : Object
     
     }
     
+    public async int run_async()
+    {
+               GLib.MainLoop loop = new GLib.MainLoop ();
+               this.complete.connect( (res, str,  stderr) => {
+                       loop.quit ();
+               });
+               
+               this.run();
+                
+               loop.run ();
+               return this.result;
+
+    
+    
+    }
+    
+    
     
 
     public void tidyup() // or kill