[nbdkit PATCH] data: don't ignore SIGPIPE
If all of the requested data has been read, the call to popen_close will close the scripts output pipe and on the next write a SIGPIPE is delivered. When the scripts inherited signalhandler is ignoring the singal, it won't be aborted by default. This happens in the test suite, as make 4.4 seems to ignore this signal. Therefore the executed scripts never stop and the testsuite never finishes. --- plugins/data/format.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/data/format.c b/plugins/data/format.c index 3667ead6790f..2319ea09475c 100644 --- a/plugins/data/format.c +++ b/plugins/data/format.c @@ -40,6 +40,7 @@ #include <stdarg.h> #include <string.h> #include <assert.h> +#include <signal.h> #define NBDKIT_API_VERSION 2 #include <nbdkit-plugin.h> @@ -1951,6 +1952,9 @@ store_script_len (struct allocator *a, char buf[BUFSIZ]; size_t n; + /* Restore SIGPIPE back to SIG_DFL, since shell can't undo SIG_IGN */ + signal (SIGPIPE, SIG_DFL); + pp = popen (script, "r"); if (pp == NULL) { nbdkit_error ("popen: %m"); base-commit: 09a61a0a00d3036ebfbc2fbadb0ba3e10a778ff3 -- 2.39.0
On Fri, Jan 13, 2023 at 05:57:35AM +0000, Thomas Weißschuh wrote:
If all of the requested data has been read, the call to popen_close will close the scripts output pipe and on the next write a SIGPIPE is delivered. When the scripts inherited signalhandler is ignoring the singal, it won't be aborted by default.
This happens in the test suite, as make 4.4 seems to ignore this signal. Therefore the executed scripts never stop and the testsuite never finishes. --- plugins/data/format.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/plugins/data/format.c b/plugins/data/format.c index 3667ead6790f..2319ea09475c 100644 --- a/plugins/data/format.c +++ b/plugins/data/format.c @@ -40,6 +40,7 @@ #include <stdarg.h> #include <string.h> #include <assert.h> +#include <signal.h>
#define NBDKIT_API_VERSION 2 #include <nbdkit-plugin.h> @@ -1951,6 +1952,9 @@ store_script_len (struct allocator *a, char buf[BUFSIZ]; size_t n;
+ /* Restore SIGPIPE back to SIG_DFL, since shell can't undo SIG_IGN */ + signal (SIGPIPE, SIG_DFL); + pp = popen (script, "r"); if (pp == NULL) { nbdkit_error ("popen: %m");
base-commit: 09a61a0a00d3036ebfbc2fbadb0ba3e10a778ff3
Thanks - pushed upstream in commit c0c31227198dbc7d26fd5955c18d0e2b27df3b84 Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
On Fri, Jan 13, 2023 at 05:57:35AM +0000, Thomas Weißschuh wrote:
If all of the requested data has been read, the call to popen_close will close the scripts output pipe and on the next write a SIGPIPE is delivered. When the scripts inherited signalhandler is ignoring the singal, it won't be aborted by default.
s/scripts/script's/2
This happens in the test suite, as make 4.4 seems to ignore this signal. Therefore the executed scripts never stop and the testsuite never finishes.
That's a bug in make: https://savannah.gnu.org/bugs/index.php?63307 but one we may indeed need to work around (along with every other impacted program).
--- plugins/data/format.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/plugins/data/format.c b/plugins/data/format.c index 3667ead6790f..2319ea09475c 100644 --- a/plugins/data/format.c +++ b/plugins/data/format.c @@ -40,6 +40,7 @@ #include <stdarg.h> #include <string.h> #include <assert.h> +#include <signal.h>
#define NBDKIT_API_VERSION 2 #include <nbdkit-plugin.h> @@ -1951,6 +1952,9 @@ store_script_len (struct allocator *a, char buf[BUFSIZ]; size_t n;
+ /* Restore SIGPIPE back to SIG_DFL, since shell can't undo SIG_IGN */ + signal (SIGPIPE, SIG_DFL); + pp = popen (script, "r"); if (pp == NULL) { nbdkit_error ("popen: %m");
ACK from my end, even if make ends up fixing their regression. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Jan 16, 2023 14:13:08 Eric Blake <eblake@redhat.com>:
On Fri, Jan 13, 2023 at 05:57:35AM +0000, Thomas Weißschuh wrote:
If all of the requested data has been read, the call to popen_close will close the scripts output pipe and on the next write a SIGPIPE is delivered. When the scripts inherited signalhandler is ignoring the singal, it won't be aborted by default.
s/scripts/script's/2
This happens in the test suite, as make 4.4 seems to ignore this signal. Therefore the executed scripts never stop and the testsuite never finishes.
That's a bug in make: https://savannah.gnu.org/bugs/index.php?63307
but one we may indeed need to work around (along with every other impacted program).
Thanks for the pointer. It also breaks the kernel build: https://lore.kernel.org/lkml/CAPOgqxFva=tOuh1UitCSN38+28q3BNXKq19rEsVNPRzRqK...
--- plugins/data/format.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/plugins/data/format.c b/plugins/data/format.c index 3667ead6790f..2319ea09475c 100644 --- a/plugins/data/format.c +++ b/plugins/data/format.c @@ -40,6 +40,7 @@ #include <stdarg.h> #include <string.h> #include <assert.h> +#include <signal.h>
#define NBDKIT_API_VERSION 2 #include <nbdkit-plugin.h> @@ -1951,6 +1952,9 @@ store_script_len (struct allocator *a, char buf[BUFSIZ]; size_t n;
+ /* Restore SIGPIPE back to SIG_DFL, since shell can't undo SIG_IGN */ + signal (SIGPIPE, SIG_DFL); + pp = popen (script, "r"); if (pp == NULL) { nbdkit_error ("popen: %m");
ACK from my end, even if make ends up fixing their regression.
-- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
participants (3)
-
Eric Blake -
Richard W.M. Jones -
Thomas Weißschuh