mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 12:18:01 +02:00
[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.
This commit is contained in:
parent
95575d7a69
commit
cdd021b5fb
3 changed files with 38 additions and 5 deletions
|
|
@ -32,6 +32,11 @@
|
|||
#include <cairo-pdf-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 pdf_closure_key;
|
||||
|
||||
typedef struct _pdf_target_closure
|
||||
|
|
@ -108,6 +113,7 @@ _cairo_boilerplate_pdf_surface_write_to_png (cairo_surface_t *surface, const cha
|
|||
pdf_target_closure_t *ptc = cairo_surface_get_user_data (surface, &pdf_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
|
||||
|
|
@ -146,7 +152,12 @@ _cairo_boilerplate_pdf_surface_write_to_png (cairo_surface_t *surface, const cha
|
|||
sprintf (command, "./pdf2png %s %s 1",
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,11 @@
|
|||
#include <cairo-ps-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 ps_closure_key;
|
||||
|
||||
typedef struct _ps_target_closure
|
||||
|
|
@ -107,6 +112,7 @@ _cairo_boilerplate_ps_surface_write_to_png (cairo_surface_t *surface, const char
|
|||
&ps_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
|
||||
|
|
@ -144,10 +150,15 @@ _cairo_boilerplate_ps_surface_write_to_png (cairo_surface_t *surface, const char
|
|||
|
||||
sprintf (command, "gs -q -r72 -g%dx%d -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=%s %s",
|
||||
ptc->width, ptc->height, filename, ptc->filename);
|
||||
if (system (command) == 0)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
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_WRITE_ERROR;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue