[libvirt] [PATCH] util: ignore SIGPIPE when writing to stderr/stdout
Peter Krempa
pkrempa at redhat.com
Mon Oct 14 06:57:02 UTC 2019
On Sat, Oct 12, 2019 at 16:04:11 +0800, Wang Yechao wrote:
> libvirtd's stderr/stdout redirected to journald by default, so if
> the journald has stopped, libvirtd and libvirtd's child process
> will receive SIGPIPE signal when writing logs to stderr/stdout.
>
> journald stopped reasons:
> 1. manual command "systemctl stop systemd-journald.service"
> 2. oom killer kill it.
What is configuration of logging for libvirtd? Libvirtd should not log
to stdout by default so I think this is more of a misconfiguration than
something needing fix in code.
For logging to the journal we use different means.
> ...
>
> Signed-off-by: Wang Yechao <wang.yechao255 at zte.com.cn>
> ---
> src/util/virlog.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/src/util/virlog.c b/src/util/virlog.c
> index 4c76fbc..127e121 100644
> --- a/src/util/virlog.c
> +++ b/src/util/virlog.c
> @@ -39,6 +39,7 @@
> # include <sys/un.h>
> #endif
> #include <fnmatch.h>
> +#include <signal.h>
>
> #include "virerror.h"
> #include "virlog.h"
> @@ -732,6 +733,9 @@ virLogOutputToFd(virLogSourcePtr source ATTRIBUTE_UNUSED,
> if (fd < 0)
> return;
>
> + if (fd == STDERR_FILENO || fd == STDOUT_FILENO)
> + signal(SIGPIPE, SIG_IGN);
man signal says:
The effects of signal() in a multithreaded process are unspecified.
NACK
More information about the libvir-list
mailing list