Chromium Code Reviews| Index: chrome/nacl/nacl_fork_delegate_linux.cc |
| diff --git a/chrome/nacl/nacl_fork_delegate_linux.cc b/chrome/nacl/nacl_fork_delegate_linux.cc |
| index 794cfdaed0ee09a22f955f1cb877af9f3d3da4a2..87170e7b4840ec62154b25dee633c90ccd2b2cd5 100644 |
| --- a/chrome/nacl/nacl_fork_delegate_linux.cc |
| +++ b/chrome/nacl/nacl_fork_delegate_linux.cc |
| @@ -13,9 +13,11 @@ |
| #include "base/eintr_wrapper.h" |
| #include "base/logging.h" |
| #include "base/file_path.h" |
| +#include "base/path_service.h" |
| #include "base/process_util.h" |
| #include "content/common/unix_domain_socket_posix.h" |
| #include "content/common/zygote_fork_delegate_linux.h" |
| +#include "chrome/common/chrome_paths.h" |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/common/nacl_helper_linux.h" |
| @@ -40,19 +42,26 @@ void NaClForkDelegate::Init(const bool sandboxed, |
| base::file_handle_mapping_vector fds_to_map; |
| fds_to_map.push_back(std::make_pair(fds[1], kNaClZygoteDescriptor)); |
| fds_to_map.push_back(std::make_pair(sandboxdesc, kNaClSandboxDescriptor)); |
| - // TODO(bradchen): Before making this the default for release builds, |
| - // replace command line switch with PathService::Get(). |
| - const std::string nacl_zygote_exe = |
| - CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| - switches::kNaClLinuxHelper); |
| + // TODO(bradchen): To make this the default for release builds, |
| + // remove command line switch. |
| ready_ = false; |
| - if (nacl_zygote_exe.length() != 0) { |
| + const bool use_helper = CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kNaClLinuxHelper); |
| + FilePath helper_exe; |
| + if (use_helper && PathService::Get(chrome::FILE_NACL_HELPER, &helper_exe)) { |
| CommandLine::StringVector argv = CommandLine::ForCurrentProcess()->argv(); |
| - argv[0] = nacl_zygote_exe; |
| + argv[0] = helper_exe.value(); |
| base::LaunchOptions options; |
| options.fds_to_remap = &fds_to_map; |
| options.clone_flags = CLONE_FS | SIGCHLD; |
| - ready_ = base::LaunchProcess(argv, options, NULL); |
| + // LD_BIND_NOW forces non-lazy binding in the dynamic linker, to |
| + // prevent the linker from trying to look at the text of the |
| + // nacl_helper program after it is already long gone. |
| + if (setenv("LD_BIND_NOW", "1", 1) != 0) { |
|
agl
2011/08/16 16:44:39
This is going to pollute the environment for all c
Brad Chen
2011/08/16 18:05:16
Done.
I agree this is much better done with optio
|
| + LOG(ERROR) << "setenv(LD_BIND_NOW, 1) failed."; |
| + } else { |
| + ready_ = base::LaunchProcess(argv, options, NULL); |
| + } |
| // parent and error cases are handled below |
| } |
| if (HANDLE_EINTR(close(fds[1])) != 0) |