[libvirt] [PATCH v3] util: Block SIGPIPE until execve in child process

Daniel P. Berrangé berrange at redhat.com
Wed Oct 16 14:04:12 UTC 2019


On Wed, Oct 16, 2019 at 06:50:33AM -0500, Eric Blake wrote:
> On 10/16/19 4:02 AM, Daniel P. Berrangé wrote:
> 
> > 
> > The challenge here is that we're in between fork + execve and want signal
> > handlers back to their defaults at time of execve.
> > 
> > If we set SIGPIPE to SIG_IGN and then execve() will that get reset back
> > to SIG_DFL automatically ?
> 
> Sadly, no.  execve() does not change whether a signal is ignored or masked
> (ignored is more common - a number of CI systems have had issues where the
> child inherits SIGPIPE ignored because the parent forgot to reset it, but
> the child wasn't expecting it; but inheriting a signal masked is also a real
> issue), with the lone exception of SIGCHLD. However, execve() _does_ change
> a signal that is being caught in the parent into SIG_DFL post-exec.
> 
> That does mean, however, that it is viable to install a no-op SIGPIPE
> handler (SIGPIPE is generated but ignored, I/O gets the EPIPE as desired),
> then post-exec the new process will have SIG_DFL.

Yeah, that's workable.

So we need virFork() to install a dummy SIGPIPE handler function that
is a no-op, *before* it unmasks signals.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list