From 3bc0fc4c4496c345c79734dcd6dc56d44119aebf Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 8 Nov 2022 10:34:22 +0200 Subject: Make process exit diagnostics consistent In particular, we now always print error message on non-0 exit except in cases where such exit is ignored. --- libbuild2/dist/operation.cxx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'libbuild2/dist/operation.cxx') diff --git a/libbuild2/dist/operation.cxx b/libbuild2/dist/operation.cxx index f6d00e4..078a8e2 100644 --- a/libbuild2/dist/operation.cxx +++ b/libbuild2/dist/operation.cxx @@ -741,7 +741,7 @@ namespace build2 if (verb >= 2) print_process (args); - run (ctx, cmd, args); + run (ctx, cmd, args, 1 /* finish_verbosity */); } // install [/] @@ -784,7 +784,7 @@ namespace build2 if (verb >= 2) print_process (args); - run (t.ctx, cmd, args); + run (t.ctx, cmd, args, 1 /* finish_verbosity */); return d / (n.empty () ? relf.leaf () : n); } @@ -957,10 +957,17 @@ namespace build2 out_fd.get () /* stdout */); cpr.in_ofd.reset (); // Close the archiver's stdout on our side. - run_finish (args.data () + i, cpr); } - run_finish (args.data (), apr); + // Delay throwing until we diagnose both ends of the pipe. + // + if (!run_finish_code (args.data (), + apr, + 1 /* verbosity */, + false /* omit_normal */) || + !(i == 0 || run_finish_code (args.data () + i, cpr, 1, false))) + throw failed (); + out_rm.cancel (); return ap; @@ -1030,7 +1037,8 @@ namespace build2 args, 0 /* stdin */, c_fd.get () /* stdout */)); - run_finish (args, pr); + + run_finish (args, pr, 1 /* verbosity */); } else { -- cgit v1.1