diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2014-12-15 07:41:29 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2014-12-15 07:49:39 +0100 |
commit | 1aab71ce61ea84cb15ed9a83ac4b2c5d22e92501 (patch) | |
tree | c2e849223fcbf2ac3c26cdc9b01fef392593849e | |
parent | 0d2e4c00d260cb22784a8736f1c571a7fbe87aa2 (diff) | |
download | sciteco-1aab71ce61ea84cb15ed9a83ac4b2c5d22e92501.tar.gz |
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
-rw-r--r-- | src/spawn.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
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 <sys/types.h> +#include <sys/wait.h> + +#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 { |