Skip to content

Commit

Permalink
dhcpcd: Improve script status handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rsmarples committed Oct 19, 2023
1 parent fd2e62e commit 9c20aab
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,24 +700,24 @@ static int
script_run(struct dhcpcd_ctx *ctx, char **argv)
{
pid_t pid;
int status = 0;
int status;

pid = script_exec(argv, ctx->script_env);
if (pid == -1)
if (pid == -1) {
logerr("%s: %s", __func__, argv[0]);
else if (pid != 0) {
/* Wait for the script to finish */
while (waitpid(pid, &status, 0) == -1) {
if (errno != EINTR) {
logerr("%s: waitpid", __func__);
status = 0;
break;
}
return -1;
} else if (pid == 0)
return 0;

/* Wait for the script to finish */
while (waitpid(pid, &status, 0) == -1) {
if (errno != EINTR) {
logerr("%s: waitpid", __func__);
status = 0;
break;
}
status = script_status(argv[0], status);
}

return WEXITSTATUS(status);
return script_status(argv[0], status);
}

int
Expand Down Expand Up @@ -771,7 +771,7 @@ script_runreason(const struct interface *ifp, const char *reason)
logdebugx("%s: executing: %s %s", ifp->name, argv[0], reason);

#ifdef PRIVSEP
if (ctx->options & DHCPCD_PRIVSEP) {
if (IN_PRIVSEP(ctx)) {
ssize_t err;

err = ps_root_script(ctx, ctx->script_buf, (size_t)buflen);
Expand Down

0 comments on commit 9c20aab

Please sign in to comment.