tests: regressions: Ignore SIGPIPE in test.

The test tests/regressions/rhbz914931.c works by causing the daemon to
segfault while writing to it.

For reasons unknown, when configured --without-libvirt, this causes
the test to fail receiving SIGPIPE (exit code 141).  We can prevent
this by installing a signal handler to ignore SIGPIPE, so the signal
is converted to EPIPE which the code handles properly.
This commit is contained in:
Richard W.M. Jones
2017-02-23 13:33:48 +00:00
parent c72be578c1
commit a7bd499244

View File

@@ -27,6 +27,7 @@
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <signal.h>
#include <errno.h>
#include <error.h>
@@ -38,6 +39,7 @@
int
main (int argc, char *argv[])
{
struct sigaction sa;
guestfs_h *g;
int r;
char *str;
@@ -50,6 +52,14 @@ main (int argc, char *argv[])
exit (77);
}
/* This test can fail with SIGPIPE (shows up as exit code 141)
* unless we ignore that signal.
*/
memset (&sa, 0, sizeof sa);
sa.sa_handler = SIG_IGN;
sa.sa_flags = SA_RESTART;
sigaction (SIGPIPE, &sa, NULL);
g = guestfs_create ();
if (!g)
error (EXIT_FAILURE, errno, "guestfs_create");