[PATCH] util: ignore SIGPIPE when writing to stderr/stdout

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
...

Signed-off-by: Wang Yechao <wang.yechao255@xxxxxxxxxx>
---
 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);
+
     if (virAsprintfQuiet(&msg, "%s: %s", timestamp, str) < 0)
         return;
 
@@ -740,6 +744,10 @@ virLogOutputToFd(virLogSourcePtr source ATTRIBUTE_UNUSED,
 
     if (flags & VIR_LOG_STACK_TRACE)
         virLogStackTraceToFd(fd);
+
+    if (fd == STDERR_FILENO || fd == STDOUT_FILENO)
+        signal(SIGPIPE, SIG_DFL);
+
 }
 
 
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux