X-Git-Url: https://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=lib%2Fprocess%2Fprocess.c;h=1a16fb6312b4fb74dc8cc753806009e939bd7691;hp=e1a158b0799519e391aa310228a3c8670cad7e47;hb=1b646fb733ef99b1dc1862276ae3595bdeaf355b;hpb=e52a8c61a640ab4fce0b4caaa796ae3e1c4ff8a3 diff --git a/lib/process/process.c b/lib/process/process.c index e1a158b..1a16fb6 100644 --- a/lib/process/process.c +++ b/lib/process/process.c @@ -29,6 +29,7 @@ struct procset { struct list async_list; int sigchld_pipe[2]; struct waiter *sigchld_waiter; + bool dry_run; }; /* Internal data type for process handling @@ -245,13 +246,14 @@ static int process_fini(void *p) return 0; } -struct procset *process_init(void *ctx, struct waitset *set) +struct procset *process_init(void *ctx, struct waitset *set, bool dry_run) { struct sigaction sa; int rc; procset = talloc(ctx, struct procset); procset->waitset = set; + procset->dry_run = dry_run; list_init(&procset->async_list); rc = pipe(procset->sigchld_pipe); @@ -330,6 +332,8 @@ static int process_run_common(struct process_info *procinfo) if (pid == 0) { process_setup_stdout_child(procinfo); + if (procset->dry_run) + exit(EXIT_SUCCESS); execvp(process->path, (char * const *)process->argv); exit(EXIT_FAILURE); } @@ -351,8 +355,13 @@ int process_run_sync(struct process *process) process_read_stdout(procinfo); - rc = waitpid(process->pid, &process->exit_status, 0); - if (rc == -1) { + for (;;) { + rc = waitpid(process->pid, &process->exit_status, 0); + if (rc >= 0) + break; + if (errno == EINTR) + continue; + pb_log("%s: waitpid failed: %s\n", __func__, strerror(errno)); return rc; }