[libvirt] [PATCH v3] util: Block SIGPIPE until execve in child process
Eric Blake
eblake at redhat.com
Wed Oct 16 02:59:46 UTC 2019
On 10/15/19 9:43 PM, Eric Blake wrote:
> On 10/15/19 9:25 PM, Wang Yechao wrote:
>> Libvirtd has set SIGPIPE to ignored, and virFork resets all signal
>> handlers to the defaults. But child process may write logs to
>> stderr/stdout, that may generate SIGPIPE if journald has stopped.
>>
>> So block SIGPIPE in virFork, and unblock it before execve.
>
> How does that help? If writing to stderr hits EOF, it will queue up a
> SIGPIPE to be delivered as soon as you unblock SIGPIPE.
>
> The correct fix is to not unblock SIGPIPE until after any point at which
> you would be performing I/O that must not fail due to SIGPIPE, rather
> than messing with signal masks to just delay when SIGPIPE is delivered.
Let's word this better:
The correct fix is to keep SIGPIPE ignored until after any point at
which you would be performing I/O that must not cause SIGPIPE, reverting
SIGPIPE back to SIG_DFL at the last possible moment. Messing with
signal masks merely delays when SIGPIPE is delivered, rather than
avoiding it.
--
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