Fix #8030 - fix multiple ref issue
[roobuilder] / src / Spawn.vala
index 7b63163..3e09e1f 100644 (file)
@@ -164,7 +164,7 @@ public class Spawn : Object
                        Process.spawn_async (   
                                this.cwd,
                                this.args,
-                               this.env.length > 0 ? this.env : GLib.Environ.get (),
+                               this.env.length > 0 ? this.env : null,
                                SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD,
                                null,
                                out pid);
@@ -234,10 +234,6 @@ 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();
                        GLib.debug("DONE TIDYUP - calling complete");
                        
@@ -329,8 +325,12 @@ public class Spawn : Object
                this.complete.connect( (res, str,  stderr) => {
                        loop.quit ();
                });
+               try {
+                       this.run();
+               } catch (GLib.Error e) {
+                       return -1;
+               }
                
-               this.run();
                 
                loop.run ();
                return this.result;