Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: base/process_util_posix.cc

Issue 11280010: Extract SIGPIPE ignoring code to a common place. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix ios Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <dirent.h> 5 #include <dirent.h>
6 #include <errno.h> 6 #include <errno.h>
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <signal.h> 8 #include <signal.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <sys/resource.h> 10 #include <sys/resource.h>
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 signal(SIGABRT, SIG_DFL); 147 signal(SIGABRT, SIG_DFL);
148 signal(SIGFPE, SIG_DFL); 148 signal(SIGFPE, SIG_DFL);
149 signal(SIGBUS, SIG_DFL); 149 signal(SIGBUS, SIG_DFL);
150 signal(SIGSEGV, SIG_DFL); 150 signal(SIGSEGV, SIG_DFL);
151 signal(SIGSYS, SIG_DFL); 151 signal(SIGSYS, SIG_DFL);
152 signal(SIGTERM, SIG_DFL); 152 signal(SIGTERM, SIG_DFL);
153 } 153 }
154 154
155 } // anonymous namespace 155 } // anonymous namespace
156 156
157 bool IgnoreSigPipe() {
158 struct sigaction action;
159 memset(&action, 0, sizeof(action));
160 action.sa_handler = SIG_IGN;
161 if (sigemptyset(&action.sa_mask) != 0)
162 return false;
163 return (sigaction(SIGPIPE, &action, NULL) == 0);
164 }
165
157 ProcessId GetCurrentProcId() { 166 ProcessId GetCurrentProcId() {
158 return getpid(); 167 return getpid();
159 } 168 }
160 169
161 ProcessHandle GetCurrentProcessHandle() { 170 ProcessHandle GetCurrentProcessHandle() {
162 return GetCurrentProcId(); 171 return GetCurrentProcId();
163 } 172 }
164 173
165 bool OpenProcessHandle(ProcessId pid, ProcessHandle* handle) { 174 bool OpenProcessHandle(ProcessId pid, ProcessHandle* handle) {
166 // On Posix platforms, process handles are the same as PIDs, so we 175 // On Posix platforms, process handles are the same as PIDs, so we
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 if (IsChildDead(process)) 1268 if (IsChildDead(process))
1260 return; 1269 return;
1261 1270
1262 BackgroundReaper* reaper = new BackgroundReaper(process, 0); 1271 BackgroundReaper* reaper = new BackgroundReaper(process, 0);
1263 PlatformThread::CreateNonJoinable(0, reaper); 1272 PlatformThread::CreateNonJoinable(0, reaper);
1264 } 1273 }
1265 1274
1266 #endif // !defined(OS_MACOSX) 1275 #endif // !defined(OS_MACOSX)
1267 1276
1268 } // namespace base 1277 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698