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 <string> | 9 #include <string> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 char* argv_copy[argv.size() + 1]; | 34 char* argv_copy[argv.size() + 1]; |
35 for (size_t i = 0; i < argv.size(); i++) { | 35 for (size_t i = 0; i < argv.size(); i++) { |
36 argv_copy[i] = new char[argv[i].size() + 1]; | 36 argv_copy[i] = new char[argv[i].size() + 1]; |
37 strcpy(argv_copy[i], argv[i].c_str()); | 37 strcpy(argv_copy[i], argv[i].c_str()); |
38 } | 38 } |
39 argv_copy[argv.size()] = NULL; | 39 argv_copy[argv.size()] = NULL; |
40 | 40 |
41 int pid = fork(); | 41 int pid = fork(); |
42 if (pid == 0) { | 42 if (pid == 0) { |
43 execv(argv_copy[0], argv_copy); | 43 execvp(argv_copy[0], argv_copy); |
44 } else if (pid < 0) { | 44 } else if (pid < 0) { |
45 retval = false; | 45 retval = false; |
46 } else { | 46 } else { |
47 if (wait) | 47 if (wait) |
48 waitpid(pid, 0, 0); | 48 waitpid(pid, 0, 0); |
49 | 49 |
50 if(process_handle) | 50 if(process_handle) |
51 *process_handle = pid; | 51 *process_handle = pid; |
52 } | 52 } |
53 | 53 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 (*io_counters).WriteTransferCount = StringToInt64(tokenizer.token()); | 316 (*io_counters).WriteTransferCount = StringToInt64(tokenizer.token()); |
317 } | 317 } |
318 state = KEY_NAME; | 318 state = KEY_NAME; |
319 break; | 319 break; |
320 } | 320 } |
321 } | 321 } |
322 return true; | 322 return true; |
323 } | 323 } |
324 | 324 |
325 } // namespace process_util | 325 } // namespace process_util |
OLD | NEW |