[libvirt] [PATCH v3] util: Block SIGPIPE until execve in child process
Eric Blake
eblake at redhat.com
Wed Oct 16 11:50:33 UTC 2019
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.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
More information about the libvir-list
mailing list