]> git.ipfire.org Git - thirdparty/libvirt.git/commit
vsh: Suppress attempts to write to stderr when it was closed in 'cmdComplete'
authorPeter Krempa <pkrempa@redhat.com>
Wed, 29 Apr 2026 10:15:34 +0000 (12:15 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 5 May 2026 05:32:11 +0000 (07:32 +0200)
commit9899c91515d79595d19800ccc895df18eb7bb3f7
tree7df8af68a7aad56624f4e121953dcacd47407a64
parenta8a06cf1c6cbab9e753f8c8ed5461a1bf6843a5d
vsh: Suppress attempts to write to stderr when it was closed in 'cmdComplete'

The completer closes stderr to suppress anything polluting the shell
when completion would cause any errors.

Since 'virshReconnect' would call 'vshError' on connection failure this
causes vshError to be killed by SIGPIPE and not provide any completions
if the connection is not possible.

To avoid this add a flag called 'stderr_closed' to vshControl and use it
to suppress output in 'vshPrintStderr'. Keep only the log.

Prior to this patch, attempt to run completion on a host with all
daemons shut down would result in:

 # virsh complete -- "start" "--doma" ; echo $?
 141
 #

With this patch the completion will still fail but the return code will
be 1. Further patch will allow completion.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/vsh.c
tools/vsh.h