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 #include "base/process_util.h" | 5 #include "base/process_util.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 #include <dirent.h> | 8 #include <dirent.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 if (process_handle) | 79 if (process_handle) |
80 *process_handle = pid; | 80 *process_handle = pid; |
81 } | 81 } |
82 | 82 |
83 for (size_t i = 0; i < argv.size(); i++) | 83 for (size_t i = 0; i < argv.size(); i++) |
84 delete[] argv_copy[i]; | 84 delete[] argv_copy[i]; |
85 | 85 |
86 return retval; | 86 return retval; |
87 } | 87 } |
| 88 |
88 bool LaunchApp(const CommandLine& cl, | 89 bool LaunchApp(const CommandLine& cl, |
89 bool wait, bool start_hidden, | 90 bool wait, bool start_hidden, |
90 ProcessHandle* process_handle) { | 91 ProcessHandle* process_handle) { |
91 file_handle_mapping_vector no_files; | 92 file_handle_mapping_vector no_files; |
92 return LaunchApp(cl.argv(), no_files, wait, process_handle); | 93 return LaunchApp(cl.argv(), no_files, wait, process_handle); |
93 } | 94 } |
94 | 95 |
95 bool DidProcessCrash(ProcessHandle handle) { | |
96 int status; | |
97 if (waitpid(handle, &status, WNOHANG)) { | |
98 // I feel like dancing! | |
99 return false; | |
100 } | |
101 | |
102 if (WIFSIGNALED(status)) { | |
103 switch(WTERMSIG(status)) { | |
104 case SIGSEGV: | |
105 case SIGILL: | |
106 case SIGABRT: | |
107 case SIGFPE: | |
108 return true; | |
109 default: | |
110 return false; | |
111 } | |
112 } | |
113 | |
114 if (WIFEXITED(status)) | |
115 return WEXITSTATUS(status) != 0; | |
116 | |
117 return false; | |
118 } | |
119 | |
120 NamedProcessIterator::NamedProcessIterator(const std::wstring& executable_name, | 96 NamedProcessIterator::NamedProcessIterator(const std::wstring& executable_name, |
121 const ProcessFilter* filter) | 97 const ProcessFilter* filter) |
122 : executable_name_(executable_name), filter_(filter) { | 98 : executable_name_(executable_name), filter_(filter) { |
123 procfs_dir_ = opendir("/proc"); | 99 procfs_dir_ = opendir("/proc"); |
124 } | 100 } |
125 | 101 |
126 NamedProcessIterator::~NamedProcessIterator() { | 102 NamedProcessIterator::~NamedProcessIterator() { |
127 if (procfs_dir_) { | 103 if (procfs_dir_) { |
128 closedir(procfs_dir_); | 104 closedir(procfs_dir_); |
129 procfs_dir_ = NULL; | 105 procfs_dir_ = NULL; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 (*io_counters).WriteTransferCount = StringToInt64(tokenizer.token()); | 295 (*io_counters).WriteTransferCount = StringToInt64(tokenizer.token()); |
320 } | 296 } |
321 state = KEY_NAME; | 297 state = KEY_NAME; |
322 break; | 298 break; |
323 } | 299 } |
324 } | 300 } |
325 return true; | 301 return true; |
326 } | 302 } |
327 | 303 |
328 } // namespace base | 304 } // namespace base |
OLD | NEW |