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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 execvp(argv_copy[0], argv_copy); | 72 execvp(argv_copy[0], argv_copy); |
73 } else if (pid < 0) { | 73 } else if (pid < 0) { |
74 retval = false; | 74 retval = false; |
75 } else { | 75 } else { |
76 if (wait) | 76 if (wait) |
77 waitpid(pid, 0, 0); | 77 waitpid(pid, 0, 0); |
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 | |
89 bool LaunchApp(const CommandLine& cl, | 88 bool LaunchApp(const CommandLine& cl, |
90 bool wait, bool start_hidden, ProcessHandle* process_handle) { | 89 bool wait, bool start_hidden, |
| 90 ProcessHandle* process_handle) { |
91 file_handle_mapping_vector no_files; | 91 file_handle_mapping_vector no_files; |
92 return LaunchApp(cl.argv(), no_files, wait, process_handle); | 92 return LaunchApp(cl.argv(), no_files, wait, process_handle); |
93 } | 93 } |
94 | 94 |
95 bool DidProcessCrash(ProcessHandle handle) { | 95 bool DidProcessCrash(ProcessHandle handle) { |
96 int status; | 96 int status; |
97 if (waitpid(handle, &status, WNOHANG)) { | 97 if (waitpid(handle, &status, WNOHANG)) { |
98 // I feel like dancing! | 98 // I feel like dancing! |
99 return false; | 99 return false; |
100 } | 100 } |
101 | 101 |
102 if (WIFSIGNALED(status)) { | 102 if (WIFSIGNALED(status)) { |
103 int signum = WTERMSIG(status); | 103 int signum = WTERMSIG(status); |
104 return (signum == SIGSEGV || signum == SIGILL || signum == SIGABRT || signum
== SIGFPE); | 104 return (signum == SIGSEGV || signum == SIGILL || signum == SIGABRT || |
| 105 signum == SIGFPE); |
105 } | 106 } |
106 | 107 |
107 if (WIFEXITED(status)) { | 108 if (WIFEXITED(status)) { |
108 int exitcode = WEXITSTATUS(status); | 109 int exitcode = WEXITSTATUS(status); |
109 return (exitcode != 0); | 110 return (exitcode != 0); |
110 } | 111 } |
111 | 112 |
112 return false; | 113 return false; |
113 } | 114 } |
114 | 115 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 (*io_counters).WriteTransferCount = StringToInt64(tokenizer.token()); | 316 (*io_counters).WriteTransferCount = StringToInt64(tokenizer.token()); |
316 } | 317 } |
317 state = KEY_NAME; | 318 state = KEY_NAME; |
318 break; | 319 break; |
319 } | 320 } |
320 } | 321 } |
321 return true; | 322 return true; |
322 } | 323 } |
323 | 324 |
324 } // namespace base | 325 } // namespace base |
OLD | NEW |