[PATCH] libvirt-guests.sh: fix log output with new systemd
Michal Privoznik
mprivozn at redhat.com
Thu Apr 30 12:09:51 UTC 2020
On 4/30/20 11:59 AM, Christian Ehrhardt wrote:
> Newer systemd is too smart, it detects the PIDs of the gettext calls
> and due to that a log lists libvirt-guests.sh with many different PIDs.
>
> Furthermore it struggles to collect the output in time, so it can be
> truncated and overall looks like:
> libvirt-guests.sh[37986]: Running guests on default URI:
> libvirt-guests.sh[37995]: Running guests on
> libvirt-guests.sh[37977]: R
>
> Gather the gettext result into a local variable and printing
> the value from libvirt-guests.sh itself fixes both issues.
>
> Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1875708
>
> Signed-off-by: Christian Ehrhardt <christian.ehrhardt at canonical.com>
> ---
> tools/libvirt-guests.sh.in | 74 +++++++++++++++++++++-----------------
> 1 file changed, 42 insertions(+), 32 deletions(-)
>
> diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in
> index 7af24dab3b..324abe3623 100644
> --- a/tools/libvirt-guests.sh.in
> +++ b/tools/libvirt-guests.sh.in
> @@ -28,6 +28,16 @@ test ! -r "$sysconfdir"/rc.d/init.d/functions ||
> # Make sure this file is recognized as having translations: _("dummy")
> . "@bindir@"/gettext.sh
>
> +# Avoid output being listed under gettext PID and being truncated
> +unbuffered_gettext () {
> + msg="$(gettext "$1")"
> + echo "$msg"
> +}
> +unbuffered_eval_gettext () {
> + msg="$(eval_gettext "$1")"
> + echo "$msg"
> +}
> +
Ah, is this the case where gettext prints the text in many sequences
whereas echo does it all at once? Or what do you think is happening
here? I don't quite understand how buffering steps into this.
Michal
More information about the libvir-list
mailing list