Chromium Code Reviews| 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 <sched.h> | 10 #include <sched.h> |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 666 | 666 |
| 667 bool GetAppOutputAndError(const CommandLine& cl, std::string* output) { | 667 bool GetAppOutputAndError(const CommandLine& cl, std::string* output) { |
| 668 // Run |execve()| with the current environment and store "unlimited" data. | 668 // Run |execve()| with the current environment and store "unlimited" data. |
| 669 int exit_code; | 669 int exit_code; |
| 670 GetAppOutputInternalResult result = GetAppOutputInternal( | 670 GetAppOutputInternalResult result = GetAppOutputInternal( |
| 671 cl.argv(), NULL, true, output, std::numeric_limits<std::size_t>::max(), | 671 cl.argv(), NULL, true, output, std::numeric_limits<std::size_t>::max(), |
| 672 true, &exit_code); | 672 true, &exit_code); |
| 673 return result == EXECUTE_SUCCESS && exit_code == EXIT_SUCCESS; | 673 return result == EXECUTE_SUCCESS && exit_code == EXIT_SUCCESS; |
| 674 } | 674 } |
| 675 | 675 |
| 676 // TODO(viettrungluu): Conceivably, we should have a timeout as well, so we | |
| 677 // don't hang if what we're calling hangs. | |
| 678 bool GetAppOutputRestricted(const CommandLine& cl, | |
| 679 std::string* output, size_t max_output) { | |
| 680 // Run |execve()| with the empty environment. | |
| 681 char* const empty_environ = NULL; | |
| 682 int exit_code; | |
| 683 GetAppOutputInternalResult result = GetAppOutputInternal( | |
|
Lei Zhang
2016/07/01 06:41:48
All the callers to GetAppOutputInternal() now pass
benwells
2016/07/04 03:07:53
Good catch. Removed now.
| |
| 684 cl.argv(), &empty_environ, false, output, max_output, false, &exit_code); | |
| 685 return result == GOT_MAX_OUTPUT || (result == EXECUTE_SUCCESS && | |
| 686 exit_code == EXIT_SUCCESS); | |
| 687 } | |
| 688 | |
| 689 bool GetAppOutputWithExitCode(const CommandLine& cl, | 676 bool GetAppOutputWithExitCode(const CommandLine& cl, |
| 690 std::string* output, | 677 std::string* output, |
| 691 int* exit_code) { | 678 int* exit_code) { |
| 692 // Run |execve()| with the current environment and store "unlimited" data. | 679 // Run |execve()| with the current environment and store "unlimited" data. |
| 693 GetAppOutputInternalResult result = GetAppOutputInternal( | 680 GetAppOutputInternalResult result = GetAppOutputInternal( |
| 694 cl.argv(), NULL, false, output, std::numeric_limits<std::size_t>::max(), | 681 cl.argv(), NULL, false, output, std::numeric_limits<std::size_t>::max(), |
| 695 true, exit_code); | 682 true, exit_code); |
| 696 return result == EXECUTE_SUCCESS; | 683 return result == EXECUTE_SUCCESS; |
| 697 } | 684 } |
| 698 | 685 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 783 jmp_buf env; | 770 jmp_buf env; |
| 784 if (setjmp(env) == 0) { | 771 if (setjmp(env) == 0) { |
| 785 return CloneAndLongjmpInChild(flags, ptid, ctid, &env); | 772 return CloneAndLongjmpInChild(flags, ptid, ctid, &env); |
| 786 } | 773 } |
| 787 | 774 |
| 788 return 0; | 775 return 0; |
| 789 } | 776 } |
| 790 #endif // defined(OS_LINUX) || defined(OS_NACL_NONSFI) | 777 #endif // defined(OS_LINUX) || defined(OS_NACL_NONSFI) |
| 791 | 778 |
| 792 } // namespace base | 779 } // namespace base |
| OLD | NEW |