From 1aab71ce61ea84cb15ed9a83ac4b2c5d22e92501 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 15 Dec 2014 07:41:29 +0100 Subject: add workaround for missing g_spawn_check_exit_status() in libglib v2.33 and earlier * Debian 7 is still at libglib v2.33 and since it should be supported, I reimplemented the missing function (UNIX-only). * This workaround can be removed once libglib v2.34 becomes common place. Closes #2 --- src/spawn.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src') diff --git a/src/spawn.cpp b/src/spawn.cpp index e346950..7b7c10f 100644 --- a/src/spawn.cpp +++ b/src/spawn.cpp @@ -31,6 +31,47 @@ #include "error.h" #include "spawn.h" +/* + * Debian 7 is still at libglib v2.33, so + * for the time being we support this UNIX-only + * implementation of g_spawn_check_exit_status() + * partially emulating libglib v2.34 + */ +#ifndef G_SPAWN_EXIT_ERROR +#ifdef G_OS_UNIX +#warning "libglib v2.34 or later recommended." +#else +#error "libglib v2.34 or later required." +#endif + +#include +#include + +#define G_SPAWN_EXIT_ERROR \ + g_quark_from_static_string("g-spawn-exit-error-quark") + +static gboolean +g_spawn_check_exit_status(gint exit_status, GError **error) +{ + if (!WIFEXITED(exit_status)) { + g_set_error(error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED, + "Abnormal process termination (%d)", + exit_status); + return FALSE; + } + + if (WEXITSTATUS(exit_status) != 0) { + g_set_error(error, G_SPAWN_EXIT_ERROR, WEXITSTATUS(exit_status), + "Unsuccessful exit status %d", + WEXITSTATUS(exit_status)); + return FALSE; + } + + return TRUE; +} + +#endif + namespace SciTECO { namespace States { -- cgit v1.2.3