diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2014-01-14 15:44:10 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2014-01-14 15:55:21 +0800 |
commit | 33527e065d9506e05f61c020a473544123c0601b (patch) | |
tree | e76ef3df4907151438406013a011e69808a8c2c0 /lib/process/process.c | |
parent | 4153ab54b5933fc315ad896e264f74571a494c90 (diff) | |
download | talos-petitboot-33527e065d9506e05f61c020a473544123c0601b.tar.gz talos-petitboot-33527e065d9506e05f61c020a473544123c0601b.zip |
lib/process: Add add_stderr flag to process module
For some process execution functions, we'd like to capture stderr as
well as stdout. Currently, we unconditionally redirect subprocess stderr
to the petitboot log file.
This change adds an add_stderr flag to struct process, which indicates
to the process library that we want stderr as well as stdout. If this is
specified, the subprocess' stderr is captured to stdout_buf.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'lib/process/process.c')
-rw-r--r-- | lib/process/process.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/process/process.c b/lib/process/process.c index 1a16fb6..3c81b29 100644 --- a/lib/process/process.c +++ b/lib/process/process.c @@ -125,7 +125,10 @@ static void process_setup_stdout_child(struct process_info *procinfo) else dup2(log, STDOUT_FILENO); - dup2(log, STDERR_FILENO); + if (procinfo->process.keep_stdout && procinfo->process.add_stderr) + dup2(procinfo->stdout_pipe[1], STDERR_FILENO); + else + dup2(log, STDERR_FILENO); } static void process_finish_stdout(struct process_info *procinfo) |