From 57a09503d72e7cb8feff5a5c1d611a4d6da8a555 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Mon, 20 Apr 2015 23:30:06 +0200 Subject: [PATCH] Fix build with Glib < 2.34 --- tools/simulator.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tools/simulator.c b/tools/simulator.c index bb4c51d..175e62f 100644 --- a/tools/simulator.c +++ b/tools/simulator.c @@ -667,15 +667,35 @@ static void _simulator_on_child_watch(GPid pid, gint status, gpointer data) static void _simulator_on_children_watch(GPid pid, gint status, gpointer data) { Simulator * simulator = data; - GError * error = NULL; size_t i; size_t s = sizeof(*simulator->children); +#if GLIB_CHECK_VERSION(2, 34, 0) + GError * error = NULL; if(g_spawn_check_exit_status(status, &error) == FALSE) { simulator_error(simulator, error->message, 1); g_error_free(error); } +#else + char buf[64]; + + if(!(WIFEXITED(status) && WEXITSTATUS(status) == 0)) + { + if(WIFEXITED(status)) + snprintf(buf, sizeof(buf), "%s%d", + _("Child exited with error code "), + WEXITSTATUS(status)); + else if(WIFSIGNALED(status)) + snprintf(buf, sizeof(buf), "%s%d", + _("Child killed with signal "), + WTERMSIG(status)); + else + snprintf(buf, sizeof(buf), "%s", + _("Child exited with an error")); + simulator_error(simulator, buf, 1); + } +#endif g_spawn_close_pid(pid); for(i = 0; i < simulator->children_cnt; i++) {