diff options
author | Mohamed Abbas <mabbas@linux.intel.com> | 2011-01-28 12:31:30 +0100 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-01-28 12:31:30 +0100 |
commit | ab4cdff6852fd5fe26ee3ad588f0200952841ffe (patch) | |
tree | 99b7aa5612cb235dd0fde7cfcb6592261da4a416 | |
parent | d211eda9950464aea25aea3fbfc0bb276b697294 (diff) | |
download | connman-ab4cdff6852fd5fe26ee3ad588f0200952841ffe.tar.gz connman-ab4cdff6852fd5fe26ee3ad588f0200952841ffe.tar.bz2 connman-ab4cdff6852fd5fe26ee3ad588f0200952841ffe.zip |
task: Pass exit code to the exit callback
-rw-r--r-- | include/task.h | 2 | ||||
-rw-r--r-- | plugins/ntpd.c | 3 | ||||
-rw-r--r-- | plugins/vpn.c | 2 | ||||
-rw-r--r-- | plugins/vpn.h | 2 | ||||
-rw-r--r-- | src/task.c | 12 |
5 files changed, 13 insertions, 8 deletions
diff --git a/include/task.h b/include/task.h index f608c7e5..bde2a29d 100644 --- a/include/task.h +++ b/include/task.h @@ -37,7 +37,7 @@ extern "C" { struct connman_task; typedef void (* connman_task_exit_t) (struct connman_task *task, - void *user_data); + int exit_code, void *user_data); typedef void (* connman_task_notify_t) (struct connman_task *task, DBusMessage *message, void *user_data); diff --git a/plugins/ntpd.c b/plugins/ntpd.c index 731fa463..3ee2ad86 100644 --- a/plugins/ntpd.c +++ b/plugins/ntpd.c @@ -109,7 +109,8 @@ static connman_bool_t ntpd_running(void) return ret; } -static void ntpdate_died(struct connman_task *task, void *user_data) +static void ntpdate_died(struct connman_task *task, + int exit_code, void *user_data) { struct ntpdate_task *ntpdate = user_data; diff --git a/plugins/vpn.c b/plugins/vpn.c index 278e0ea3..e1b6404b 100644 --- a/plugins/vpn.c +++ b/plugins/vpn.c @@ -102,7 +102,7 @@ static int kill_tun(char *tun_name) return 0; } -void vpn_died(struct connman_task *task, void *user_data) +void vpn_died(struct connman_task *task, int exit_code, void *user_data) { struct connman_provider *provider = user_data; struct vpn_data *data = connman_provider_get_data(provider); diff --git a/plugins/vpn.h b/plugins/vpn.h index b2afff5b..86e1f73c 100644 --- a/plugins/vpn.h +++ b/plugins/vpn.h @@ -38,4 +38,4 @@ struct vpn_driver { int vpn_register(const char *name, struct vpn_driver *driver, const char *program); void vpn_unregister(const char *provider_name); -void vpn_died(struct connman_task *task, void *user_data); +void vpn_died(struct connman_task *task, int exit_code, void *user_data); @@ -246,11 +246,15 @@ int connman_task_set_notify(struct connman_task *task, const char *member, static void task_died(GPid pid, gint status, gpointer user_data) { struct connman_task *task = user_data; + int exit_code; - if (WIFEXITED(status)) - DBG("task %p exit status %d", task, WEXITSTATUS(status)); - else + if (WIFEXITED(status)) { + exit_code = WEXITSTATUS(status); + DBG("task %p exit status %d", task, exit_code); + } else { + exit_code = 0; DBG("task %p signal %d", task, WTERMSIG(status)); + } g_spawn_close_pid(pid); task->pid = -1; @@ -258,7 +262,7 @@ static void task_died(GPid pid, gint status, gpointer user_data) task->child_watch = 0; if (task->exit_func) - task->exit_func(task, task->exit_data); + task->exit_func(task, exit_code, task->exit_data); } static void task_setup(gpointer user_data) |