[Libguestfs] [PATCH nbdkit] server: When using --run, wait for captive nbdkit to exit.

Eric Blake eblake at redhat.com
Thu Feb 27 15:39:51 UTC 2020


On 2/27/20 9:12 AM, Richard W.M. Jones wrote:
> In tests/test-eval.sh we have a test which looks something like this:
> 
>    nbdkit eval close='echo closed > file' --run 'qemu-img info $nbd'
>    if ! grep 'closed' file; then fail; fi
> 
> However there was a race condition here.  nbdkit exits when the --run
> command exits without waiting for the captive nbdkit subprocess.  Thus
> we couldn't be sure that the final 'closed' message got written to the
> file.  It worked most of the time, but on slow machines the test
> failed.
> 
> This indicates that we ought to wait for the captive nbdkit to exit.
> One reason is so that plugin cleanup is done before we continue after
> the captive nbdkit.  That should make shell scripts using captive
> nbdkit + any plugin that does significant cleanup on exit more
> predictable.
> 
> This adds the appropriate call to waitpid but we still ignore the exit
> status of the captive nbdkit subprocess (in fact it is most likely to
> fail since it will sent a SIGTERM signal).
> ---
>   server/captive.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)

ACK.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




More information about the Libguestfs mailing list