-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Marcel Holtmann
Sent: Tuesday, December 08, 2009 4:00 PM
To: [email protected]
Subject: Re: [PATCH 3/7] Subject: [PATCH 3/7] support pipe spawn.
Hi Mohamed,
> add an option to allow process spawn with pipe support.
this patch is actually broken. I did fix it for you :)
> diff --git a/include/task.h b/include/task.h
> index 76639d4..2239188 100644
> --- a/include/task.h
> +++ b/include/task.h
> @@ -56,7 +56,8 @@ int connman_task_set_notify(struct connman_task *task,
> const char *member,
> connman_task_notify_t function, void *user_data);
>
> int connman_task_run(struct connman_task *task,
> - connman_task_exit_t function, void *user_data);
> + connman_task_exit_t function, void *user_data,
> + int *fd, int *standard_output, int *standard_error);
> int connman_task_stop(struct connman_task *task);
>
> #ifdef __cplusplus
> diff --git a/plugins/dhclient.c b/plugins/dhclient.c
> index fc42024..fa0a8c3 100644
> --- a/plugins/dhclient.c
> +++ b/plugins/dhclient.c
> @@ -207,7 +207,8 @@ static int dhclient_request(struct connman_dhcp *dhcp)
> connman_task_set_notify(dhclient->task, "Notify",
> dhclient_notify, dhcp);
>
> - connman_task_run(dhclient->task, dhclient_died, dhclient);
> + connman_task_run(dhclient->task, dhclient_died, dhclient,
> + NULL, NULL, NULL);
>
> return 0;
> }
> diff --git a/src/task.c b/src/task.c
> index f5495d7..3997307 100644
> --- a/src/task.c
> +++ b/src/task.c
> @@ -267,12 +267,15 @@ static void task_setup(gpointer user_data)
> * @task: task structure
> * @function: exit callback
> * @user_data: optional exit user data
> + * @fd: optional spawn with pipe
> *
> * Execute program specified by #task
> */
> int connman_task_run(struct connman_task *task,
> - connman_task_exit_t function, void *user_data)
> + connman_task_exit_t function, void *user_data,
> + int *fd, int *standard_output, int *standard_error)
> {
> + gboolean result;
> GSpawnFlags flags = G_SPAWN_DO_NOT_REAP_CHILD |
> G_SPAWN_STDOUT_TO_DEV_NULL;
> char **argv, **envp;
> @@ -282,6 +285,11 @@ int connman_task_run(struct connman_task *task,
> if (task->pid > 0)
> return -EALREADY;
>
> + if (standard_output == NULL)
> + flags |= G_SPAWN_STDOUT_TO_DEV_NULL;
> + if (standard_error == NULL)
> + flags |= G_SPAWN_STDERR_TO_DEV_NULL;
> +
Since G_SPAWN_STDOUT_TO_DEV_NULL is always set, then the output check is
a bit pointless right?
Actually flags set to initialized to G_SPAWN_DO_NOT_REAP_CHILD only then OR
G_SPAWN_STDOUT_TO_DEV_NULL if that condition met. I can submit a patch later to
reflect this
> task->exit_func = function;
> task->exit_data = user_data;
>
> @@ -312,8 +320,12 @@ int connman_task_run(struct connman_task *task,
> argv = (char **) task->argv->pdata;
> envp = (char **) task->envp->pdata;
>
> - if (g_spawn_async(NULL, argv, envp, flags,
> - task_setup, task, &task->pid, NULL) == FALSE) {
> + result = g_spawn_async_with_pipes(NULL, argv, envp,
> + G_SPAWN_DO_NOT_REAP_CHILD,
> + task_setup, task, &task->pid,
> + fd, standard_output,
> + standard_output, NULL);
You forgot to use actually the flags.
I need to pass the flag instead
Regards
Marcel
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman