From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me>
---
cmd/hare/build/queue.ha | 8 ++++++--
cmd/hare/build/types.ha | 1 +
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/cmd/hare/build/queue.ha b/cmd/hare/build/queue.ha
index 973f9350..51309459 100644
--- a/cmd/hare/build/queue.ha
+++ b/cmd/hare/build/queue.ha
@@ -175,10 +175,12 @@ fn run_task(ctx: *context, jobs: *[]job, t: *task) (bool | error) = {
defer io::close(output)!;
exec::addfile(&cmd, os::stdout_file, output);
exec::addfile(&cmd, os::stderr_file, output);
+ let args = strings::join(" ", args...);
static append(jobs, job {
pid = exec::start(&cmd)?,
task = t,
lock = lock,
+ args = args,
});
return true;
};
@@ -222,10 +224,12 @@ fn await_task(ctx: *context, jobs: *[]job) (size | void | error) = {
if (ctx.mode == output::DEFAULT) {
fmt::errorln()?;
};
- fmt::fatal(ctx.mods[t.idx].name, ctx.cmds[t.kind],
- exec::exitstr(e));
+
+ fmt::fatalf("Failed {} job ({}), command: {} {}",
+ ctx.mods[t.idx].name, exec::exitstr(e), ctx.cmds[t.kind], j.args);
};
+ free(j.args);
cleanup_task(ctx, t)?;
free_task(t);
io::close(j.lock)?;
diff --git a/cmd/hare/build/types.ha b/cmd/hare/build/types.ha
index 43470df5..433d0437 100644
--- a/cmd/hare/build/types.ha
+++ b/cmd/hare/build/types.ha
@@ -51,6 +51,7 @@ export type job = struct {
// fd to be closed once the job has finished, in order to release the
// [[io::lock]] on it
lock: io::file,
+ args: str,
};
export type output = enum {
--
2.41.0
On Sun Oct 1, 2023 at 17:54 MSK, Haelwenn (lanodan) Monnier wrote:
> diff --git a/cmd/hare/build/queue.ha b/cmd/hare/build/queue.ha
> index 973f9350..51309459 100644
> --- a/cmd/hare/build/queue.ha
> +++ b/cmd/hare/build/queue.ha
> @@ -175,10 +175,12 @@ fn run_task(ctx: *context, jobs: *[]job, t: *task) (bool | error) = {
> defer io::close(output)!;
> exec::addfile(&cmd, os::stdout_file, output);
> exec::addfile(&cmd, os::stderr_file, output);
> + let args = strings::join(" ", args...);
This should use shlex::quote like case output::VVERBOSE above in this function.
memio::dynamic can be used to write it into a string, or alternatively, store
the args slice in the task and quote only when reporting the error.
> + free(j.args);
This should be moved to free_task since there are different codepaths where a
task is freed, which would leak args.