diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2019-06-16 20:09:42 +0800 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2019-06-19 05:25:24 +0200 |
commit | 26bd0dfc1b3c11ba9f0562b657b8b58333b2c459 (patch) | |
tree | 8cee798228b60c81be43d9b4c85dcf86dcd8195c /src/node_process_object.cc | |
parent | 17a5eba6c271c5faa89bd8a6434cad150aeeb98e (diff) | |
download | android-node-v8-26bd0dfc1b3c11ba9f0562b657b8b58333b2c459.tar.gz android-node-v8-26bd0dfc1b3c11ba9f0562b657b8b58333b2c459.tar.bz2 android-node-v8-26bd0dfc1b3c11ba9f0562b657b8b58333b2c459.zip |
src: save exec path when initializing Environment
PR-URL: https://github.com/nodejs/node/pull/28252
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_process_object.cc')
-rw-r--r-- | src/node_process_object.cc | 40 |
1 files changed, 9 insertions, 31 deletions
diff --git a/src/node_process_object.cc b/src/node_process_object.cc index 4547025406..54ae8e6a21 100644 --- a/src/node_process_object.cc +++ b/src/node_process_object.cc @@ -180,37 +180,15 @@ void PatchProcessObject(const FunctionCallbackInfo<Value>& args) { #undef V // process.execPath - { - char exec_path_buf[2 * PATH_MAX]; - size_t exec_path_len = sizeof(exec_path_buf); - std::string exec_path; - if (uv_exepath(exec_path_buf, &exec_path_len) == 0) { - exec_path = std::string(exec_path_buf, exec_path_len); - } else { - exec_path = env->argv()[0]; - } - // On OpenBSD process.execPath will be relative unless we - // get the full path before process.execPath is used. -#if defined(__OpenBSD__) - uv_fs_t req; - req.ptr = nullptr; - if (0 == - uv_fs_realpath(env->event_loop(), &req, exec_path.c_str(), nullptr)) { - CHECK_NOT_NULL(req.ptr); - exec_path = std::string(static_cast<char*>(req.ptr)); - } - uv_fs_req_cleanup(&req); -#endif - process - ->Set(context, - FIXED_ONE_BYTE_STRING(isolate, "execPath"), - String::NewFromUtf8(isolate, - exec_path.c_str(), - NewStringType::kInternalized, - exec_path.size()) - .ToLocalChecked()) - .Check(); - } + process + ->Set(context, + FIXED_ONE_BYTE_STRING(isolate, "execPath"), + String::NewFromUtf8(isolate, + env->exec_path().c_str(), + NewStringType::kInternalized, + env->exec_path().size()) + .ToLocalChecked()) + .Check(); // process.debugPort CHECK(process |