if (this.cfg.debug) {
- stdout.printf("cd %s; %s\n" , this.cfg.cwd , string.joinv(" ", this.cfg.args));
+ GLib.debug("cd %s; %s\n" , this.cfg.cwd , string.joinv(" ", this.cfg.args));
}
+ // stdout:
+ if (!this.cfg.async) {
+ string ls_stdout;
+ string ls_stderr;
+ int ls_status;
+
+ Process.spawn_sync (
+ this.cfg.cwd,
+ this.cfg.args,
+ this.cfg.env,
+ SpawnFlags.SEARCH_PATH,
+ null,
+ out ls_stdout,
+ out ls_stderr,
+ out ls_status
+ );
+ this.output = ls_stdout;
+ this.stderr = ls_stderr;
+ this.result = ls_status;
+ if (this.cfg.exceptions && this.result != 0) {
+ var errstr = string.joinv(" ", this.cfg.args) + "\n";
+ errstr += this.output;
+ errstr += this.output.length > 0 ? "\n" : "";
+ errstr += this.stderr;
+ //print("Throwing execute error:%s\n", errstr);
+ throw new SpawnError.EXECUTE_ERROR(errstr);
+ //this.toString = function() { return this.stderr; };
+ ///throw new Exception this; // we throw self...
+ }
+ return;
+
+ }
+
+
+
+
Process.spawn_async_with_pipes (
this.cfg.cwd,
this.cfg.args,
out standard_output,
out standard_error);
- // stdout:
+
//print(JSON.stringify(gret));
if (this.cfg.debug) {
- stdout.printf("PID: %d\n" ,this.pid);
+ GLib.debug("PID: %d\n" ,this.pid);
}
this.ref(); // additional ref - cleared on tidyup...
if (this.pid > -1) {
// child can exit before we get this far..
if (this.cfg.input != null) {
- if (this.cfg.debug) print("Trying to call listeners");
+ if (this.cfg.debug) GLib.debug("Trying to call listeners");
try {
this.write(this.cfg.input());
// this probably needs to be a bit smarter...
if (this.pid > -1) {
//print("starting main loop");
- //if (this.cfg.debug) {
- //
- // }
+ if (this.cfg.debug) {
+ GLib.debug("starting main loop");
+ }
this.ctx = new MainLoop ();
this.ctx.run(); // wait fore exit?
-
+ if (this.cfg.debug) {
+ GLib.debug(" main loop done");
+ }
//print("main_loop done!");
} else {
this.tidyup(); // tidyup get's called in main loop.
private void tidyup()
{
+ if (this.cfg.debug) {
+ GLib.debug("tidyup");
+ }
+
//print("Tidyup\n");
if (this.pid > -1) {
Process.close_pid(this.pid); // hopefully kills it..