Skip to content

Commit

Permalink
exec* never returns so always exiting without checking return value
Browse files Browse the repository at this point in the history
  • Loading branch information
miki725 committed Mar 22, 2024
1 parent b2a881d commit 8c93448
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions nimutils/c/subproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,21 +403,18 @@ setup_subscriptions(subprocess_t *ctx, bool pty)
static void
subproc_do_exec(subprocess_t *ctx)
{
int error;
if (ctx->envp) {
error = execve(ctx->cmd, ctx->argv, ctx->envp);
execve(ctx->cmd, ctx->argv, ctx->envp);
}
else {
error = execv(ctx->cmd, ctx->argv);
}
if (error == -1) {
fprintf(stderr, "%s: %s\n",ctx->cmd, strerror(errno));
exit(1);
}

// If we get past the exec, kill the subproc, which will
// tear down the switchboard.
abort();
execv(ctx->cmd, ctx->argv);
}
// If we get past the exec, kill the subproc with non-zero exit code,
// which will tear down the switchboard and print to stderr the
// errono description. For example for nonexisting command will be:
// foo: No such file or directory
fprintf(stderr, "%s: %s\n",ctx->cmd, strerror(errno));
exit(1);
}

party_t *
Expand Down

0 comments on commit 8c93448

Please sign in to comment.