diff options
Diffstat (limited to 'src/task.c')
-rwxr-xr-x | src/task.c | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -45,8 +45,10 @@ struct connman_task { GPtrArray *argv; GPtrArray *envp; connman_task_exit_t exit_func; + connman_task_setup_t setup_func; void *exit_data; GHashTable *notify; + void *setup_data; }; static GHashTable *task_hash = NULL; @@ -93,7 +95,9 @@ static void free_task(gpointer data) * * Returns: a newly-allocated #connman_task structure */ -struct connman_task *connman_task_create(const char *program) +struct connman_task *connman_task_create(const char *program, + connman_task_setup_t custom_task_setup, + void *setup_data) { struct connman_task *task; gint counter; @@ -116,9 +120,13 @@ struct connman_task *connman_task_create(const char *program) str = g_strdup(program); g_ptr_array_add(task->argv, str); + task->setup_func = custom_task_setup; + task->notify = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); + task->setup_data = setup_data; + DBG("task %p", task); g_hash_table_insert(task_hash, task->path, task); @@ -130,7 +138,7 @@ struct connman_task *connman_task_create(const char *program) * connman_task_destory: * @task: task structure * - * Remove and destory #task + * Remove and destroy #task */ void connman_task_destroy(struct connman_task *task) { @@ -220,7 +228,7 @@ int connman_task_add_variable(struct connman_task *task, /** * connman_task_set_notify: * @task: task structure - * @member: notifcation method name + * @member: notification method name * @function: notification callback * @user_data: optional notification user data * @@ -277,6 +285,9 @@ static void task_setup(gpointer user_data) sigemptyset(&mask); if (sigprocmask(SIG_SETMASK, &mask, NULL) < 0) connman_error("Failed to clean signal mask"); + + if (task->setup_func) + task->setup_func(task->setup_data); } /** |