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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 RAW_LOG(FATAL, "Cound not fix sa_restorer."); | 174 RAW_LOG(FATAL, "Cound not fix sa_restorer."); |
175 } | 175 } |
176 #endif // !defined(NDEBUG) | 176 #endif // !defined(NDEBUG) |
177 } | 177 } |
178 } | 178 } |
179 #endif // !defined(OS_LINUX) || | 179 #endif // !defined(OS_LINUX) || |
180 // (!defined(__i386__) && !defined(__x86_64__) && !defined(__arm__)) | 180 // (!defined(__i386__) && !defined(__x86_64__) && !defined(__arm__)) |
181 | 181 |
182 } // anonymous namespace | 182 } // anonymous namespace |
183 | 183 |
184 // A class to handle auto-closing of DIR*'s. | 184 // Functor for |ScopedDIR| (below). |
185 class ScopedDIRClose { | 185 struct ScopedDIRClose { |
186 public: | |
187 inline void operator()(DIR* x) const { | 186 inline void operator()(DIR* x) const { |
188 if (x) { | 187 if (x) |
189 closedir(x); | 188 closedir(x); |
190 } | |
191 } | 189 } |
192 }; | 190 }; |
193 typedef scoped_ptr_malloc<DIR, ScopedDIRClose> ScopedDIR; | 191 |
| 192 // Automatically closes |DIR*|s. |
| 193 typedef scoped_ptr<DIR, ScopedDIRClose> ScopedDIR; |
194 | 194 |
195 #if defined(OS_LINUX) | 195 #if defined(OS_LINUX) |
196 static const char kFDDir[] = "/proc/self/fd"; | 196 static const char kFDDir[] = "/proc/self/fd"; |
197 #elif defined(OS_MACOSX) | 197 #elif defined(OS_MACOSX) |
198 static const char kFDDir[] = "/dev/fd"; | 198 static const char kFDDir[] = "/dev/fd"; |
199 #elif defined(OS_SOLARIS) | 199 #elif defined(OS_SOLARIS) |
200 static const char kFDDir[] = "/dev/fd"; | 200 static const char kFDDir[] = "/dev/fd"; |
201 #elif defined(OS_FREEBSD) | 201 #elif defined(OS_FREEBSD) |
202 static const char kFDDir[] = "/dev/fd"; | 202 static const char kFDDir[] = "/dev/fd"; |
203 #elif defined(OS_OPENBSD) | 203 #elif defined(OS_OPENBSD) |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 std::string* output, | 631 std::string* output, |
632 int* exit_code) { | 632 int* exit_code) { |
633 // Run |execve()| with the current environment and store "unlimited" data. | 633 // Run |execve()| with the current environment and store "unlimited" data. |
634 GetAppOutputInternalResult result = GetAppOutputInternal( | 634 GetAppOutputInternalResult result = GetAppOutputInternal( |
635 cl.argv(), NULL, output, std::numeric_limits<std::size_t>::max(), true, | 635 cl.argv(), NULL, output, std::numeric_limits<std::size_t>::max(), true, |
636 exit_code); | 636 exit_code); |
637 return result == EXECUTE_SUCCESS; | 637 return result == EXECUTE_SUCCESS; |
638 } | 638 } |
639 | 639 |
640 } // namespace base | 640 } // namespace base |
OLD | NEW |