lib/process: Add raw stdout mode
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Tue, 14 Feb 2017 04:52:35 +0000 (15:52 +1100)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Tue, 15 Aug 2017 03:03:28 +0000 (13:03 +1000)
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>
lib/process/process.c
lib/process/process.h

index f7e5b8faa2d1af4595fb479fe3d39b429184ad90..c1606a52b342406de99d44d9cd07a678a327ba29 100644 (file)
@@ -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
index f858b0edc11ce344f36e6644dfba157dd634237f..4904ffc8f5126977f1407bcb8d08703ea5b57037 100644 (file)
@@ -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;