Skip to content

Feature Request: Samurai without posix spawn? #111

@Sunny-Maxis

Description

@Sunny-Maxis

Colleague of mine has asked me to pass on this request.

Samurai will not build on certain OSes due to the non-negotiable use of posix_spawn in how it handles child processes.

However, muon, another project, embeds Samurai without the use of this syscall.

Their version:

`static bool
samu_jobstart(struct samu_ctx *ctx, struct samu_job *j, struct samu_edge *e)
{
size_t i;
struct samu_node *n;
struct samu_string *rspfile, *content;

++ctx->build.nstarted;
for (i = 0; i < e->nout; ++i) {
    n = e->out[i];
    if (n->mtime == SAMU_MTIME_MISSING) {
        if (samu_makedirs(n->path, true) < 0)
            return false;
    }
}

rspfile = samu_edgevar(ctx, e, "rspfile", false);
if (rspfile) {
    content = samu_edgevar(ctx, e, "rspfile_content", true);
    if (samu_writefile(rspfile->s, content) < 0)
        return false;
}

j->edge = e;
j->cmd = samu_edgevar(ctx, e, "command", true);
j->cmd_ctx = (struct run_cmd_ctx){
    .flags = run_cmd_ctx_flag_async,
};

if (e->pool == &ctx->consolepool) {
    j->cmd_ctx.flags |= run_cmd_ctx_flag_dont_capture;
}

if (!ctx->build.consoleused)
    samu_printstatus(ctx, e, j->cmd);

bool cmd_started = false;
if (build_machine.is_windows) {
    cmd_started = run_cmd_unsplit(&j->cmd_ctx, j->cmd->s, 0, 0);
} else {
    char *argv[] = { "/bin/sh", "-c", j->cmd->s, NULL };
    cmd_started = run_cmd_argv(&j->cmd_ctx, argv, 0, 0);
}

if (!cmd_started) {
    samu_warn("failed to start job: %s", j->cmd_ctx.err_msg);
    j->failed = true;
    return false;
}

j->failed = false;
if (e->pool == &ctx->consolepool)
    ctx->build.consoleused = true;

return true;

}
`

Is it possible for someone to make this happen?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions