- print("PID: " + this.pid);
- }
-
- ChildWatch.add (this.pid, (w_pid, result) => {
-
- this.result = result;
- if (_this.debug) {
- print("child_watch_add : result: " + result);
- }
-
- this.read(this.out_ch);
- this.read(this.err_ch);
-
-
- Process.close_pid(this.pid);
- this.pid = -1;
- if (_this.ctx) {
- _this.ctx.quit();
- }
- tidyup();
- //print("DONE TIDYUP");
- if (_this.listeners.finish) {
- _this.listeners.finish.call(this, _this.result);
- }
- });
-
- // Triggered when the child indicated by child_pid exits
- Process.close_pid (w_pid);
- loop.quit ();
- })
-
- GLib.child_watch_add(GLib.PRIORITY_DEFAULT, this.pid, function(pid, result) {
-
-
- function tidyup()
- {
- if (_this.pid) {
- GLib.spawn_close_pid(_this.pid); // hopefully kills it..
- _this.pid = false;
- }
- if (_this.in_ch) _this.in_ch.close();
- if (_this.out_ch) _this.out_ch.close();
- if (_this.err_ch) _this.err_ch.close();
- // blank out channels
- _this.in_ch = false;
- _this.err_ch = false;
- _this.out_ch = false;
- // rmeove listeners !! important otherwise we kill the CPU
- if (err_src !== false) GLib.source_remove(err_src);
- if (out_src !== false) GLib.source_remove(out_src);
- err_src = false;
- out_src = false;