Re: [PATCH] util: ignore SIGPIPE when writing tostderr/stdout

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

 



> On Sat, Oct 12, 2019 at 04:04:11PM +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"
>
> Don't do that then IMHO.

I just do it to reproduce this scenes.

> > 2. oom killer kill it.
> > ...
>
> If OOM killer picked journald, then it is game over for the host IMHO
> and thed right answer is a reboot. This would be very surprising though.
> OOM killer is more likely to pick QEMU or libvirtd as they're bigger
> targets.
>

Reboot is the best way. But sometimes, the oom is caused by a abnormal process,
if we stop it, the system's free memory will back to normal. And i think it's
no need to reboot.

> >
> > 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);
>
> This is very wrong....
>
> This code is run in both client & server, so we're messing with SIGPIPE
> in applications that link to libvirt.so.
>

Thanks to point my fault.

> The use of signal() is not safe in multi-threaded applications.
>
> In libvirtd we have set SIGPIPE to ignored already when starting up
> libvirtd.

Can set SIGPIPE to ignored in the child process that forked by libvirtd ?

---
Best wishes
Wang Yechao
--
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