summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordmichael@google.com <dmichael@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-16 18:39:43 +0000
committerdmichael@google.com <dmichael@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-16 18:39:43 +0000
commitc4db9a19988a098e28c6d5718f3d8f5bfb3f2fd6 (patch)
tree015ca41c4d18b3c1b9e68094746279c9f7316139
parent8355c43370924931547c5923065c33ae15009202 (diff)
downloadchromium_src-c4db9a19988a098e28c6d5718f3d8f5bfb3f2fd6.zip
chromium_src-c4db9a19988a098e28c6d5718f3d8f5bfb3f2fd6.tar.gz
chromium_src-c4db9a19988a098e28c6d5718f3d8f5bfb3f2fd6.tar.bz2
Revert 168239 - Extract SIGPIPE ignoring code to a common place.
Failed compile on Linux Clang: http://build.chromium.org/p/chromium.linux/builders/Linux%20Clang%20%28dbg%29/builds/35971/steps/compile/logs/stdio ../../chrome/test/webdriver/webdriver_server.cc:230:8:error: use of undeclared identifier 'IgnoreSigPipe'; did you mean 'base::IgnoreSigPipe'? if (!IgnoreSigPipe()) { ^~~~~~~~~~~~~ base::IgnoreSigPipe ../../base/process_util.h:153:18: note: 'base::IgnoreSigPipe' declared here BUG=none Review URL: https://codereview.chromium.org/11280010 TBR=phajdan.jr@chromium.org Review URL: https://codereview.chromium.org/11308073 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168248 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/debug/stack_trace_android.cc9
-rw-r--r--base/debug/stack_trace_posix.cc7
-rw-r--r--base/process_util.h6
-rw-r--r--base/process_util_posix.cc9
-rw-r--r--chrome/browser/chromeos/web_socket_proxy.cc15
-rw-r--r--chrome/test/webdriver/webdriver_server.cc8
-rw-r--r--content/app/content_main_runner.cc2
-rw-r--r--net/tools/flip_server/flip_in_mem_edsm_server.cc3
8 files changed, 28 insertions, 31 deletions
diff --git a/base/debug/stack_trace_android.cc b/base/debug/stack_trace_android.cc
index 2d9a422..cc03d60 100644
--- a/base/debug/stack_trace_android.cc
+++ b/base/debug/stack_trace_android.cc
@@ -9,7 +9,6 @@
#include <unistd.h>
#include "base/logging.h"
-#include "base/process_util.h"
namespace base {
namespace debug {
@@ -18,8 +17,12 @@ bool EnableInProcessStackDumping() {
// When running in an application, our code typically expects SIGPIPE
// to be ignored. Therefore, when testing that same code, it should run
// with SIGPIPE ignored as well.
- // TODO(phajdan.jr): Ignoring SIGPIPE has nothing to do with stack dumping.
- return base::IgnoreSigPipe();
+ // TODO(phajdan.jr): De-duplicate this SIGPIPE code.
+ struct sigaction action;
+ memset(&action, 0, sizeof(action));
+ action.sa_handler = SIG_IGN;
+ sigemptyset(&action.sa_mask);
+ return (sigaction(SIGPIPE, &action, NULL) == 0);
}
StackTrace::StackTrace() {
diff --git a/base/debug/stack_trace_posix.cc b/base/debug/stack_trace_posix.cc
index 1ccee68..6c90b2b 100644
--- a/base/debug/stack_trace_posix.cc
+++ b/base/debug/stack_trace_posix.cc
@@ -30,7 +30,6 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/posix/eintr_wrapper.h"
-#include "base/process_util.h"
#include "base/string_number_conversions.h"
#if defined(USE_SYMBOLIZE)
@@ -302,7 +301,11 @@ bool EnableInProcessStackDumping() {
// When running in an application, our code typically expects SIGPIPE
// to be ignored. Therefore, when testing that same code, it should run
// with SIGPIPE ignored as well.
- bool success = base::IgnoreSigPipe();
+ struct sigaction action;
+ memset(&action, 0, sizeof(action));
+ action.sa_handler = SIG_IGN;
+ sigemptyset(&action.sa_mask);
+ bool success = (sigaction(SIGPIPE, &action, NULL) == 0);
// Avoid hangs during backtrace initialization, see above.
WarmUpBacktrace();
diff --git a/base/process_util.h b/base/process_util.h
index 00135c4..2805e42 100644
--- a/base/process_util.h
+++ b/base/process_util.h
@@ -147,12 +147,6 @@ BASE_EXPORT extern size_t g_oom_size;
BASE_EXPORT void RouteStdioToConsole();
#endif
-#if defined(OS_POSIX)
-// Ignores SIGPIPE signal. We handle pipe errors in a different way.
-// Returns true on success.
-BASE_EXPORT bool IgnoreSigPipe() WARN_UNUSED_RESULT;
-#endif
-
// Returns the id of the current process.
BASE_EXPORT ProcessId GetCurrentProcId();
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc
index 9bc19e3..a19cc2a 100644
--- a/base/process_util_posix.cc
+++ b/base/process_util_posix.cc
@@ -154,15 +154,6 @@ void ResetChildSignalHandlersToDefaults() {
} // anonymous namespace
-bool IgnoreSigPipe() {
- struct sigaction action;
- memset(&action, 0, sizeof(action));
- action.sa_handler = SIG_IGN;
- if (sigemptyset(&action.sa_mask) != 0)
- return false;
- return (sigaction(SIGPIPE, &action, NULL) == 0);
-}
-
ProcessId GetCurrentProcId() {
return getpid();
}
diff --git a/chrome/browser/chromeos/web_socket_proxy.cc b/chrome/browser/chromeos/web_socket_proxy.cc
index 4edae06..f1ef630 100644
--- a/chrome/browser/chromeos/web_socket_proxy.cc
+++ b/chrome/browser/chromeos/web_socket_proxy.cc
@@ -32,7 +32,6 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop.h"
-#include "base/process_util.h"
#include "base/sequenced_task_runner_helpers.h"
#include "base/sha1.h"
#include "base/stl_util.h"
@@ -102,6 +101,18 @@ bool SetNonBlock(int fd) {
return flags >= 0 && fcntl(fd, F_SETFL, flags | O_NONBLOCK) == 0;
}
+// Returns true on success.
+bool IgnoreSigPipe() {
+ struct sigaction sa;
+ sa.sa_handler = SIG_IGN;
+ sa.sa_flags = 0;
+ if (sigemptyset(&sa.sa_mask) || sigaction(SIGPIPE, &sa, 0)) {
+ LOG(ERROR) << "WebSocketProxy: Failed to disable sigpipe";
+ return false;
+ }
+ return true;
+}
+
uint64 ReadNetworkInteger(uint8* buf, int num_bytes) {
uint64 rv = 0;
DCHECK_GE(num_bytes, 0);
@@ -910,7 +921,7 @@ void Serv::Run() {
if (evdns_init())
LOG(WARNING) << "WebSocketProxy: Failed to initialize evDNS";
- if (!base::IgnoreSigPipe()) {
+ if (!IgnoreSigPipe()) {
LOG(ERROR) << "WebSocketProxy: Failed to ignore SIGPIPE";
return;
}
diff --git a/chrome/test/webdriver/webdriver_server.cc b/chrome/test/webdriver/webdriver_server.cc
index 5781bac..ccb8c70 100644
--- a/chrome/test/webdriver/webdriver_server.cc
+++ b/chrome/test/webdriver/webdriver_server.cc
@@ -19,7 +19,6 @@
#include "base/file_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
-#include "base/process_util.h"
#include "base/stringprintf.h"
#include "base/string_number_conversions.h"
#include "base/string_split.h"
@@ -227,11 +226,8 @@ int RunChromeDriver() {
CommandLine* cmd_line = CommandLine::ForCurrentProcess();
#if defined(OS_POSIX)
- if (!IgnoreSigPipe()) {
- LOG(ERROR) << "Failed to ignore SIGPIPE";
- return EXIT_FAILURE;
- }
-#endif // defined(OS_POSIX)
+ signal(SIGPIPE, SIG_IGN);
+#endif
srand((unsigned int)time(NULL));
// Register Chrome's path provider so that the AutomationProxy will find our
diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc
index e35c8e4..22115ce 100644
--- a/content/app/content_main_runner.cc
+++ b/content/app/content_main_runner.cc
@@ -222,7 +222,7 @@ void SetupSignalHandlers() {
}
// Always ignore SIGPIPE. We check the return value of write().
- CHECK(base::IgnoreSigPipe());
+ CHECK(signal(SIGPIPE, SIG_IGN) != SIG_ERR);
}
#endif // OS_POSIX && !OS_IOS
diff --git a/net/tools/flip_server/flip_in_mem_edsm_server.cc b/net/tools/flip_server/flip_in_mem_edsm_server.cc
index 0e1a08f..8ba1505 100644
--- a/net/tools/flip_server/flip_in_mem_edsm_server.cc
+++ b/net/tools/flip_server/flip_in_mem_edsm_server.cc
@@ -13,7 +13,6 @@
#include "base/command_line.h"
#include "base/logging.h"
-#include "base/process_util.h"
#include "base/synchronization/lock.h"
#include "base/timer.h"
#include "net/tools/flip_server/acceptor_thread.h"
@@ -164,7 +163,7 @@ int main (int argc, char**argv)
bool wait_for_iface = false;
int pidfile_fd;
- CHECK(base::IgnoreSigPipe());
+ signal(SIGPIPE, SIG_IGN);
signal(SIGTERM, SignalHandler);
signal(SIGINT, SignalHandler);
signal(SIGHUP, SignalHandler);