summaryrefslogtreecommitdiff
path: root/boilerplate/cairo-boilerplate-svg.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-08-18 17:48:55 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2008-08-18 17:56:21 +0100
commitcdd021b5fbeb53247e6e1aa7224a8faa60249dc7 (patch)
tree1e8daca5152d9b72a12bedf5a0d87f361667778d /boilerplate/cairo-boilerplate-svg.c
parent95575d7a6977a21960818f81aa267725edcd8d93 (diff)
downloadcairo-cdd021b5fbeb53247e6e1aa7224a8faa60249dc7.tar.gz
[boilerplate] Check exit code from system for trapped signals.
If the external conversion utility was killed by a signal (e.g. the user sent SIGINT), raise that signal within our process as well. This means that a crash inside poppler or rsvg will be flagged as a crash inside the test suite, and makes interrupting the test suite far more responsive.
Diffstat (limited to 'boilerplate/cairo-boilerplate-svg.c')
-rw-r--r--boilerplate/cairo-boilerplate-svg.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/boilerplate/cairo-boilerplate-svg.c b/boilerplate/cairo-boilerplate-svg.c
index d931847fb..afa5634c2 100644
--- a/boilerplate/cairo-boilerplate-svg.c
+++ b/boilerplate/cairo-boilerplate-svg.c
@@ -32,6 +32,11 @@
#include <cairo-svg-surface-private.h>
#include <cairo-paginated-surface-private.h>
+#if HAVE_SIGNAL_H
+#include <stdlib.h>
+#include <signal.h>
+#endif
+
cairo_user_data_key_t svg_closure_key;
typedef struct _svg_target_closure
@@ -101,6 +106,7 @@ _cairo_boilerplate_svg_surface_write_to_png (cairo_surface_t *surface, const cha
svg_target_closure_t *ptc = cairo_surface_get_user_data (surface, &svg_closure_key);
char command[4096];
cairo_status_t status;
+ int exitstatus;
/* Both surface and ptc->target were originally created at the
* same dimensions. We want a 1:1 copy here, so we first clear any
@@ -139,7 +145,12 @@ _cairo_boilerplate_svg_surface_write_to_png (cairo_surface_t *surface, const cha
sprintf (command, "./svg2png %s %s",
ptc->filename, filename);
- if (system (command) != 0)
+ exitstatus = system (command);
+#if _XOPEN_SOURCE && HAVE_SIGNAL_H
+ if (WIFSIGNALED (exitstatus))
+ raise (WTERMSIG (exitstatus));
+#endif
+ if (exitstatus)
return CAIRO_STATUS_WRITE_ERROR;
return CAIRO_STATUS_SUCCESS;