OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 | 5 |
| 6 #include "base/logging.h" |
6 #include "base/process_util.h" | 7 #include "base/process_util.h" |
7 | 8 |
8 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
9 #include <spawn.h> | 10 #include <spawn.h> |
10 #include <string> | 11 #include <string> |
11 #include <sys/types.h> | 12 #include <sys/types.h> |
12 #include <sys/wait.h> | 13 #include <sys/wait.h> |
13 | 14 |
14 namespace base { | 15 namespace base { |
15 | 16 |
16 bool LaunchApp(const std::vector<std::string>& argv, | 17 bool LaunchApp(const std::vector<std::string>& argv, |
17 bool wait, ProcessHandle* process_handle) { | 18 bool wait, ProcessHandle* process_handle) { |
18 bool retval = true; | 19 bool retval = true; |
19 | 20 |
20 char* argv_copy[argv.size() + 1]; | 21 char* argv_copy[argv.size() + 1]; |
21 for (size_t i = 0; i < argv.size(); i++) { | 22 for (size_t i = 0; i < argv.size(); i++) { |
22 argv_copy[i] = const_cast<char*>(argv[i].c_str()); | 23 argv_copy[i] = const_cast<char*>(argv[i].c_str()); |
23 } | 24 } |
24 argv_copy[argv.size()] = NULL; | 25 argv_copy[argv.size()] = NULL; |
25 | 26 |
26 int pid = 0; | 27 int pid = 0; |
27 int spawn_succeeded = (posix_spawn(&pid, | 28 int spawn_succeeded = (posix_spawnp(&pid, |
28 argv_copy[0], | 29 argv_copy[0], |
29 NULL, | 30 NULL, |
30 NULL, | 31 NULL, |
31 argv_copy, | 32 argv_copy, |
32 NULL) == 0); | 33 NULL) == 0); |
33 | 34 |
34 bool process_handle_valid = pid > 0; | 35 bool process_handle_valid = pid > 0; |
35 if (!spawn_succeeded || !process_handle_valid) { | 36 if (!spawn_succeeded || !process_handle_valid) { |
36 retval = false; | 37 retval = false; |
37 } else { | 38 } else { |
38 if (wait) | 39 if (wait) |
39 waitpid(pid, 0, 0); | 40 waitpid(pid, 0, 0); |
40 | 41 |
41 if(process_handle) | 42 if(process_handle) |
42 *process_handle = pid; | 43 *process_handle = pid; |
(...skipping 13 matching lines...) Expand all Loading... |
56 int status; | 57 int status; |
57 waitpid(handle, &status, 0); | 58 waitpid(handle, &status, 0); |
58 return WIFEXITED(status); | 59 return WIFEXITED(status); |
59 } | 60 } |
60 | 61 |
61 bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) { | 62 bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) { |
62 // TODO(pinkerton): can we implement this? On linux it relies on /proc. | 63 // TODO(pinkerton): can we implement this? On linux it relies on /proc. |
63 return false; | 64 return false; |
64 } | 65 } |
65 | 66 |
| 67 int GetProcessCount(const std::wstring& executable_name, |
| 68 const ProcessFilter* filter) { |
| 69 NOTIMPLEMENTED(); |
| 70 return 0; |
| 71 } |
| 72 |
| 73 bool CleanupProcesses(const std::wstring& executable_name, |
| 74 int wait_milliseconds, |
| 75 int exit_code, |
| 76 const ProcessFilter* filter) { |
| 77 NOTIMPLEMENTED(); |
| 78 return false; |
| 79 } |
| 80 |
66 } // namespace base | 81 } // namespace base |
OLD | NEW |