summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGeoff Levand <geoff@infradead.org>2018-08-02 17:29:35 +0000
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2018-08-07 11:30:36 +1000
commit214de247193d14a2de014e5e4cad1ab3df956c13 (patch)
tree02b144e050bda45fe8a32625c6daa459f86a7b87 /lib
parentecc2146363f272c5e34a4878d2144a01041d453f (diff)
downloadtalos-petitboot-214de247193d14a2de014e5e4cad1ab3df956c13.zip
talos-petitboot-214de247193d14a2de014e5e4cad1ab3df956c13.tar.gz
lib/process: Cleanup stdout callback
General cleanup of async stdout processing. The process_stdout_cb and process_stdout_custom routines were doing the same thing, so rename process_stdout_custom to process_process_stdout and make process_stdout_cb a wrapper that calls process_process_stdout. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/process/process.c32
-rw-r--r--lib/process/process.h2
2 files changed, 9 insertions, 25 deletions
diff --git a/lib/process/process.c b/lib/process/process.c
index 1fa0bb0..bc392dc 100644
--- a/lib/process/process.c
+++ b/lib/process/process.c
@@ -178,28 +178,7 @@ static int process_read_stdout(struct process_info *procinfo)
return rc < 0 ? rc : 0;
}
-static int process_stdout_cb(void *arg)
-{
- struct process_info *procinfo = arg;
- int rc;
-
- rc = process_read_stdout_once(procinfo, NULL);
-
- /* if we're going to signal to the waitset that we're done (ie, non-zero
- * return value), then the waiters will remove us, so we drop the
- * reference */
- if (rc < 0) {
- talloc_unlink(procset, procinfo);
- procinfo->stdout_waiter = NULL;
- rc = -1;
- } else {
- rc = 0;
- }
-
- return rc;
-}
-
-int process_stdout_custom(struct process_info *procinfo, char **line)
+int process_process_stdout(struct process_info *procinfo, char **line)
{
int rc;
@@ -417,10 +396,14 @@ int process_run_sync(struct process *process)
return 0;
}
+static int process_stdout_cb(struct process_info *procinfo)
+{
+ return process_process_stdout(procinfo, NULL);
+}
+
int process_run_async(struct process *process)
{
struct process_info *procinfo = get_info(process);
- waiter_cb stdout_cb;
int rc;
rc = process_run_common(procinfo);
@@ -428,7 +411,8 @@ int process_run_async(struct process *process)
return rc;
if (process->keep_stdout) {
- stdout_cb = process->stdout_cb ?: process_stdout_cb;
+ waiter_cb stdout_cb = process->stdout_cb ?:
+ (waiter_cb)process_stdout_cb;
procinfo->stdout_waiter = waiter_register_io(procset->waitset,
procinfo->stdout_pipe[0],
WAIT_IN, stdout_cb, procinfo);
diff --git a/lib/process/process.h b/lib/process/process.h
index 4904ffc..003ff8e 100644
--- a/lib/process/process.h
+++ b/lib/process/process.h
@@ -87,6 +87,6 @@ bool process_exit_ok(struct process *process);
/* Functions to assist callers using a custom stdout callback */
struct process *procinfo_get_process(struct process_info *procinfo);
-int process_stdout_custom(struct process_info *procinfo, char **line);
+int process_process_stdout(struct process_info *procinfo, char **line);
#endif /* PROCESS_H */
OpenPOWER on IntegriCloud