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

Side by Side Diff: base/process_util_posix.cc

Issue 118469: compile on openbsd: mostly ifdefs and missing includes,... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 6 months 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 }; 97 };
98 typedef scoped_ptr_malloc<DIR, ScopedDIRClose> ScopedDIR; 98 typedef scoped_ptr_malloc<DIR, ScopedDIRClose> ScopedDIR;
99 99
100 void CloseSuperfluousFds(const base::InjectiveMultimap& saved_mapping) { 100 void CloseSuperfluousFds(const base::InjectiveMultimap& saved_mapping) {
101 #if defined(OS_LINUX) 101 #if defined(OS_LINUX)
102 static const rlim_t kSystemDefaultMaxFds = 8192; 102 static const rlim_t kSystemDefaultMaxFds = 8192;
103 static const char fd_dir[] = "/proc/self/fd"; 103 static const char fd_dir[] = "/proc/self/fd";
104 #elif defined(OS_MACOSX) 104 #elif defined(OS_MACOSX)
105 static const rlim_t kSystemDefaultMaxFds = 256; 105 static const rlim_t kSystemDefaultMaxFds = 256;
106 static const char fd_dir[] = "/dev/fd"; 106 static const char fd_dir[] = "/dev/fd";
107 #elif defined(OS_OPENBSD)
108 static const rlim_t kSystemDefaultMaxFds = 256;
109 static const char fd_dir[] = "/dev/fd";
107 #endif 110 #endif
108 std::set<int> saved_fds; 111 std::set<int> saved_fds;
109 112
110 // Get the maximum number of FDs possible. 113 // Get the maximum number of FDs possible.
111 struct rlimit nofile; 114 struct rlimit nofile;
112 rlim_t max_fds; 115 rlim_t max_fds;
113 if (getrlimit(RLIMIT_NOFILE, &nofile)) { 116 if (getrlimit(RLIMIT_NOFILE, &nofile)) {
114 // getrlimit failed. Take a best guess. 117 // getrlimit failed. Take a best guess.
115 max_fds = kSystemDefaultMaxFds; 118 max_fds = kSystemDefaultMaxFds;
116 DLOG(ERROR) << "getrlimit(RLIMIT_NOFILE) failed: " << errno; 119 DLOG(ERROR) << "getrlimit(RLIMIT_NOFILE) failed: " << errno;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 176 }
174 } 177 }
175 178
176 // Sets all file descriptors to close on exec except for stdin, stdout 179 // Sets all file descriptors to close on exec except for stdin, stdout
177 // and stderr. 180 // and stderr.
178 // TODO(agl): Remove this function. It's fundamentally broken for multithreaded 181 // TODO(agl): Remove this function. It's fundamentally broken for multithreaded
179 // apps. 182 // apps.
180 void SetAllFDsToCloseOnExec() { 183 void SetAllFDsToCloseOnExec() {
181 #if defined(OS_LINUX) 184 #if defined(OS_LINUX)
182 const char fd_dir[] = "/proc/self/fd"; 185 const char fd_dir[] = "/proc/self/fd";
183 #elif defined(OS_MACOSX) 186 #elif defined(OS_MACOSX) || defined(OS_OPENBSD)
184 const char fd_dir[] = "/dev/fd"; 187 const char fd_dir[] = "/dev/fd";
185 #endif 188 #endif
186 ScopedDIR dir_closer(opendir(fd_dir)); 189 ScopedDIR dir_closer(opendir(fd_dir));
187 DIR *dir = dir_closer.get(); 190 DIR *dir = dir_closer.get();
188 if (NULL == dir) { 191 if (NULL == dir) {
189 DLOG(ERROR) << "Unable to open " << fd_dir; 192 DLOG(ERROR) << "Unable to open " << fd_dir;
190 return; 193 return;
191 } 194 }
192 195
193 struct dirent *ent; 196 struct dirent *ent;
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 const ProcessFilter* filter) { 534 const ProcessFilter* filter) {
532 bool exited_cleanly = 535 bool exited_cleanly =
533 WaitForProcessesToExit(executable_name, wait_milliseconds, 536 WaitForProcessesToExit(executable_name, wait_milliseconds,
534 filter); 537 filter);
535 if (!exited_cleanly) 538 if (!exited_cleanly)
536 KillProcesses(executable_name, exit_code, filter); 539 KillProcesses(executable_name, exit_code, filter);
537 return exited_cleanly; 540 return exited_cleanly;
538 } 541 }
539 542
540 } // namespace base 543 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698