Skip to content

Commit

Permalink
lib/process: Add raw stdout mode
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
sammj committed Aug 15, 2017
1 parent 8b46ab9 commit 2914110
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/process/process.c
Expand Up @@ -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;
Expand All @@ -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]);
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/process/process.h
Expand Up @@ -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;
Expand Down

0 comments on commit 2914110

Please sign in to comment.