On Tue, Aug 27, 2019 at 08:31:26AM -0500, Eric Blake wrote:
Alternative fix: instead of closing stdin/out for -s, open /dev/null
and
dup2() it over stdin/out. That has the same effect of ending the client
connection, but leaves the fds allocated so that this assert() still
works as-is, then we don't have to do any fd shuffling. That's
certainly a smaller patch to write.
I had a play around with implementing that, but I'm not sure that it
would be the right thing to do.
We still have the problem of how to deal with nbdkit being run with
fd=0, 1 or 2 being closed, which will still cause this assertion to be
thrown elsewhere:
$ perl -e 'close STDIN; close STDOUT; system ("nbdkit -fv sh
/tmp/min.sh")'
nbdkit: debug: TLS disabled: could not load TLS certificates
nbdkit: debug: registering plugin /usr/lib64/nbdkit/plugins/nbdkit-sh-plugin.so
nbdkit: debug: registered plugin /usr/lib64/nbdkit/plugins/nbdkit-sh-plugin.so (name sh)
nbdkit: debug: sh: load
nbdkit: debug: sh: load: tmpdir: /tmp/nbdkitshWLQqWC
nbdkit: debug: sh: config key=script, value=/tmp/min.sh
nbdkit: debug: /tmp/min.sh: invoking load ...
nbdkit: call.c:155: call3: Assertion `in_fd[0] > STDERR_FILENO && in_fd[1] >
STDERR_FILENO && out_fd[0] > STDERR_FILENO && out_fd[1] >
STDERR_FILENO && err_fd[0] > STDERR_FILENO && err_fd[1] >
STDERR_FILENO' failed.
While it's obviously a bug in the caller to run nbdkit like this, I
think we should consider making nbdkit a bit more robust to it as an
appeal of nbdkit is that it can be used in embedded-style situations.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top