diff options
Diffstat (limited to 'src/plugins/test_lib.c')
-rw-r--r-- | src/plugins/test_lib.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/plugins/test_lib.c b/src/plugins/test_lib.c index 97d4dc5..8bd6d4e 100644 --- a/src/plugins/test_lib.c +++ b/src/plugins/test_lib.c @@ -26,6 +26,7 @@ #include "test_lib.h" #include <sys/types.h> #include <regex.h> +#include <signal.h> /** * Function that libextractor calls for each @@ -174,6 +175,33 @@ run (const char *plugin_name, } +#ifndef WINDOWS +/** + * Install a signal handler to ignore SIGPIPE. + */ +static void +ignore_sigpipe () +{ + struct sigaction oldsig; + struct sigaction sig; + + memset (&sig, 0, sizeof (struct sigaction)); + sig.sa_handler = SIG_IGN; + sigemptyset (&sig.sa_mask); +#ifdef SA_INTERRUPT + sig.sa_flags = SA_INTERRUPT; /* SunOS */ +#else + sig.sa_flags = SA_RESTART; +#endif + if (0 != sigaction (SIGPIPE, &sig, &oldsig)) + fprintf (stderr, + "Failed to install SIGPIPE handler: %s\n", strerror (errno)); +} + + +#endif + + /** * Main function to be called to test a plugin. * @@ -191,7 +219,10 @@ ET_main (const char *plugin_name, /* change environment to find plugins which may not yet be not installed but should be in the current directory (or .libs) on 'make check' */ - if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/")) +#ifndef WINDOWS + ignore_sigpipe (); +#endif + if (0 != putenv ("LIBEXTRACTOR_PREFIX=./.libs/")) fprintf (stderr, "Failed to update my environment, plugin loading may fail: %s\n", strerror (errno)); |