mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
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:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user