OLD | NEW |
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 "base/process/launch.h" | 5 #include "base/process/launch.h" |
6 | 6 |
7 #include <dirent.h> | 7 #include <dirent.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <signal.h> | 10 #include <signal.h> |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 InjectiveMultimap::const_iterator j; | 223 InjectiveMultimap::const_iterator j; |
224 for (j = saved_mapping.begin(); j != saved_mapping.end(); j++) { | 224 for (j = saved_mapping.begin(); j != saved_mapping.end(); j++) { |
225 if (fd == j->dest) | 225 if (fd == j->dest) |
226 break; | 226 break; |
227 } | 227 } |
228 if (j != saved_mapping.end()) | 228 if (j != saved_mapping.end()) |
229 continue; | 229 continue; |
230 | 230 |
231 // Since we're just trying to close anything we can find, | 231 // Since we're just trying to close anything we can find, |
232 // ignore any error return values of close(). | 232 // ignore any error return values of close(). |
233 ignore_result(HANDLE_EINTR(close(fd))); | 233 close(fd); |
234 } | 234 } |
235 return; | 235 return; |
236 } | 236 } |
237 | 237 |
238 const int dir_fd = fd_dir.fd(); | 238 const int dir_fd = fd_dir.fd(); |
239 | 239 |
240 for ( ; fd_dir.Next(); ) { | 240 for ( ; fd_dir.Next(); ) { |
241 // Skip . and .. entries. | 241 // Skip . and .. entries. |
242 if (fd_dir.name()[0] == '.') | 242 if (fd_dir.name()[0] == '.') |
243 continue; | 243 continue; |
(...skipping 13 matching lines...) Expand all Loading... |
257 if (i != saved_mapping.end()) | 257 if (i != saved_mapping.end()) |
258 continue; | 258 continue; |
259 if (fd == dir_fd) | 259 if (fd == dir_fd) |
260 continue; | 260 continue; |
261 | 261 |
262 // When running under Valgrind, Valgrind opens several FDs for its | 262 // When running under Valgrind, Valgrind opens several FDs for its |
263 // own use and will complain if we try to close them. All of | 263 // own use and will complain if we try to close them. All of |
264 // these FDs are >= |max_fds|, so we can check against that here | 264 // these FDs are >= |max_fds|, so we can check against that here |
265 // before closing. See https://bugs.kde.org/show_bug.cgi?id=191758 | 265 // before closing. See https://bugs.kde.org/show_bug.cgi?id=191758 |
266 if (fd < static_cast<int>(max_fds)) { | 266 if (fd < static_cast<int>(max_fds)) { |
267 int ret = HANDLE_EINTR(close(fd)); | 267 int ret = IGNORE_EINTR(close(fd)); |
268 DPCHECK(ret == 0); | 268 DPCHECK(ret == 0); |
269 } | 269 } |
270 } | 270 } |
271 } | 271 } |
272 | 272 |
273 bool LaunchProcess(const std::vector<std::string>& argv, | 273 bool LaunchProcess(const std::vector<std::string>& argv, |
274 const LaunchOptions& options, | 274 const LaunchOptions& options, |
275 ProcessHandle* process_handle) { | 275 ProcessHandle* process_handle) { |
276 size_t fd_shuffle_size = 0; | 276 size_t fd_shuffle_size = 0; |
277 if (options.fds_to_remap) { | 277 if (options.fds_to_remap) { |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 std::string* output, | 629 std::string* output, |
630 int* exit_code) { | 630 int* exit_code) { |
631 // Run |execve()| with the current environment and store "unlimited" data. | 631 // Run |execve()| with the current environment and store "unlimited" data. |
632 GetAppOutputInternalResult result = GetAppOutputInternal( | 632 GetAppOutputInternalResult result = GetAppOutputInternal( |
633 cl.argv(), NULL, output, std::numeric_limits<std::size_t>::max(), true, | 633 cl.argv(), NULL, output, std::numeric_limits<std::size_t>::max(), true, |
634 exit_code); | 634 exit_code); |
635 return result == EXECUTE_SUCCESS; | 635 return result == EXECUTE_SUCCESS; |
636 } | 636 } |
637 | 637 |
638 } // namespace base | 638 } // namespace base |
OLD | NEW |