summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-08-20 10:14:22 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-08-20 10:14:44 +0800
commit815df381d55e09fd291145ef2b86729c12583366 (patch)
tree9c76855645e36b35168b98a479583d8c7370c387 /lib
parent51c6aaf7864eb65779d548ee2549caa357f71e2c (diff)
downloadtalos-petitboot-815df381d55e09fd291145ef2b86729c12583366.tar.gz
talos-petitboot-815df381d55e09fd291145ef2b86729c12583366.zip
lib/process: Add dry_run argument to process_init
Implement dry-run behaviour on the discover server by passing a bool to process_init. UIs don't need to support dry runs. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/process/process.c6
-rw-r--r--lib/process/process.h2
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/process/process.c b/lib/process/process.c
index e1a158b..6fac649 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);
}
diff --git a/lib/process/process.h b/lib/process/process.h
index 9e2a2d1..caeda92 100644
--- a/lib/process/process.h
+++ b/lib/process/process.h
@@ -47,7 +47,7 @@ struct process {
* process_create. The pointer returned can be talloc_free()-ed, or can be
* automatically freed through destruction of the ctx talloc tree.
*/
-struct procset *process_init(void *ctx, struct waitset *set);
+struct procset *process_init(void *ctx, struct waitset *set, bool dry_run);
struct process *process_create(void *ctx);
OpenPOWER on IntegriCloud