Commit f7a6e0cc authored by Wanchang Ryu's avatar Wanchang Ryu Committed by Commit Bot

Ignore SIGPIPE for service process

With --disable-in-process-stack-traces command-line flag, service
process doesn't set signal handler for SIGPIPE.
This causes crash when write() failed.

This patch set SIGPIPE to SIG_IGN regardless
--disable-in-process-stack-traces to get return value of write()

Bug: 1026188
Change-Id: I11fcde7b38b7e6fa522cf17a50ebee6e62673177
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1924094Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#717693}
parent c5bb9d2e
...@@ -80,6 +80,9 @@ constexpr size_t kMaximumMojoMessageSize = 128 * 1024 * 1024; ...@@ -80,6 +80,9 @@ constexpr size_t kMaximumMojoMessageSize = 128 * 1024 * 1024;
// Setup signal-handling state: resanitize most signals, ignore SIGPIPE. // Setup signal-handling state: resanitize most signals, ignore SIGPIPE.
void SetupSignalHandlers() { void SetupSignalHandlers() {
// Always ignore SIGPIPE. We check the return value of write().
CHECK_NE(SIG_ERR, signal(SIGPIPE, SIG_IGN));
if (base::CommandLine::ForCurrentProcess()->HasSwitch( if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableInProcessStackTraces)) { switches::kDisableInProcessStackTraces)) {
// Don't interfere with sanitizer signal handlers. // Don't interfere with sanitizer signal handlers.
...@@ -101,9 +104,6 @@ void SetupSignalHandlers() { ...@@ -101,9 +104,6 @@ void SetupSignalHandlers() {
for (unsigned i = 0; i < base::size(signals_to_reset); i++) { for (unsigned i = 0; i < base::size(signals_to_reset); i++) {
CHECK_EQ(0, sigaction(signals_to_reset[i], &sigact, NULL)); CHECK_EQ(0, sigaction(signals_to_reset[i], &sigact, NULL));
} }
// Always ignore SIGPIPE. We check the return value of write().
CHECK_NE(SIG_ERR, signal(SIGPIPE, SIG_IGN));
} }
void PopulateFDsFromCommandLine() { void PopulateFDsFromCommandLine() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment