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 @@ | |||
26 | #include "test_lib.h" | 26 | #include "test_lib.h" |
27 | #include <sys/types.h> | 27 | #include <sys/types.h> |
28 | #include <regex.h> | 28 | #include <regex.h> |
29 | #include <signal.h> | ||
29 | 30 | ||
30 | /** | 31 | /** |
31 | * Function that libextractor calls for each | 32 | * Function that libextractor calls for each |
@@ -174,6 +175,33 @@ run (const char *plugin_name, | |||
174 | } | 175 | } |
175 | 176 | ||
176 | 177 | ||
178 | #ifndef WINDOWS | ||
179 | /** | ||
180 | * Install a signal handler to ignore SIGPIPE. | ||
181 | */ | ||
182 | static void | ||
183 | ignore_sigpipe () | ||
184 | { | ||
185 | struct sigaction oldsig; | ||
186 | struct sigaction sig; | ||
187 | |||
188 | memset (&sig, 0, sizeof (struct sigaction)); | ||
189 | sig.sa_handler = SIG_IGN; | ||
190 | sigemptyset (&sig.sa_mask); | ||
191 | #ifdef SA_INTERRUPT | ||
192 | sig.sa_flags = SA_INTERRUPT; /* SunOS */ | ||
193 | #else | ||
194 | sig.sa_flags = SA_RESTART; | ||
195 | #endif | ||
196 | if (0 != sigaction (SIGPIPE, &sig, &oldsig)) | ||
197 | fprintf (stderr, | ||
198 | "Failed to install SIGPIPE handler: %s\n", strerror (errno)); | ||
199 | } | ||
200 | |||
201 | |||
202 | #endif | ||
203 | |||
204 | |||
177 | /** | 205 | /** |
178 | * Main function to be called to test a plugin. | 206 | * Main function to be called to test a plugin. |
179 | * | 207 | * |
@@ -191,7 +219,10 @@ ET_main (const char *plugin_name, | |||
191 | /* change environment to find plugins which may not yet be | 219 | /* change environment to find plugins which may not yet be |
192 | not installed but should be in the current directory (or .libs) | 220 | not installed but should be in the current directory (or .libs) |
193 | on 'make check' */ | 221 | on 'make check' */ |
194 | if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/")) | 222 | #ifndef WINDOWS |
223 | ignore_sigpipe (); | ||
224 | #endif | ||
225 | if (0 != putenv ("LIBEXTRACTOR_PREFIX=./.libs/")) | ||
195 | fprintf (stderr, | 226 | fprintf (stderr, |
196 | "Failed to update my environment, plugin loading may fail: %s\n", | 227 | "Failed to update my environment, plugin loading may fail: %s\n", |
197 | strerror (errno)); | 228 | strerror (errno)); |