lib/process: Add add_stderr flag to process module
[petitboot] / lib / process / process.c
index 6fac6492eeedd2524c71de8d4ee620a73cc3b47b..3c81b29340f8ae69ccd99f4ebe10133eb408e47d 100644 (file)
@@ -125,7 +125,10 @@ static void process_setup_stdout_child(struct process_info *procinfo)
        else
                dup2(log, STDOUT_FILENO);
 
        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)
 }
 
 static void process_finish_stdout(struct process_info *procinfo)
@@ -355,8 +358,13 @@ int process_run_sync(struct process *process)
 
        process_read_stdout(procinfo);
 
 
        process_read_stdout(procinfo);
 
-       rc = waitpid(process->pid, &process->exit_status, 0);
-       if (rc == -1) {
+       for (;;) {
+               rc = waitpid(process->pid, &process->exit_status, 0);
+               if (rc >= 0)
+                       break;
+               if (errno == EINTR)
+                       continue;
+
                pb_log("%s: waitpid failed: %s\n", __func__, strerror(errno));
                return rc;
        }
                pb_log("%s: waitpid failed: %s\n", __func__, strerror(errno));
                return rc;
        }