summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2017-02-14 15:52:35 +1100
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2017-08-15 13:03:28 +1000
commit2914110af0cc490566446f18c929452368121b98 (patch)
tree62367adb4dc3ba417525786d70587141742d7b77
parent8b46ab92aeff52b7354bf4f250835f75b4bd824c (diff)
downloadtalos-petitboot-2914110af0cc490566446f18c929452368121b98.zip
talos-petitboot-2914110af0cc490566446f18c929452368121b98.tar.gz
lib/process: Add raw stdout mode
Allow process users to set 'raw_stdout', which if set skips redirecting and saving output from processes. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
-rw-r--r--lib/process/process.c7
-rw-r--r--lib/process/process.h1
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/process/process.c b/lib/process/process.c
index f7e5b8f..c1606a5 100644
--- a/lib/process/process.c
+++ b/lib/process/process.c
@@ -114,7 +114,7 @@ static int process_setup_stdout_pipe(struct process_info *procinfo)
{
int rc;
- if (!procinfo->process.keep_stdout)
+ if (!procinfo->process.keep_stdout || procinfo->process.raw_stdout)
return 0;
procinfo->stdout_buf_len = 4096;
@@ -132,7 +132,7 @@ static int process_setup_stdout_pipe(struct process_info *procinfo)
static void process_setup_stdout_parent(struct process_info *procinfo)
{
- if (!procinfo->process.keep_stdout)
+ if (!procinfo->process.keep_stdout || procinfo->process.raw_stdout)
return;
close(procinfo->stdout_pipe[1]);
@@ -142,6 +142,9 @@ static void process_setup_stdout_child(struct process_info *procinfo)
{
int log = fileno(pb_log_get_stream());
+ if (procinfo->process.raw_stdout)
+ return;
+
if (procinfo->process.keep_stdout)
dup2(procinfo->stdout_pipe[1], STDOUT_FILENO);
else
diff --git a/lib/process/process.h b/lib/process/process.h
index f858b0e..4904ffc 100644
--- a/lib/process/process.h
+++ b/lib/process/process.h
@@ -33,6 +33,7 @@ struct process {
const char **argv;
bool keep_stdout;
bool add_stderr;
+ bool raw_stdout;
process_exit_cb exit_cb;
void *data;
waiter_cb stdout_cb;
OpenPOWER on IntegriCloud