@@ -158,7 +158,7 @@ static int busybox_progress_cb(void *arg)
p = procinfo_get_process(procinfo);
handler = p->stdout_data;
- rc = process_stdout_custom(procinfo, &line);
+ rc = process_process_stdout(procinfo, &line);
if (rc) {
/* Unregister ourselves from progress tracking */
@@ -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);
@@ -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 */
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> --- discover/paths.c | 2 +- lib/process/process.c | 32 ++++++++------------------------ lib/process/process.h | 2 +- 3 files changed, 10 insertions(+), 26 deletions(-)