mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: launch crash when null device is disabled on Windows (#47870)
fix: fix launch crash when null device is disabled on Windows add node flag node::ProcessInitializationFlags::kNoStdioInitialization Co-authored-by: yangzuohui <yangzuohui@bytedance.com> Co-authored-by: yangliu <yangliu.leo@bytedance.com>
This commit is contained in:
@@ -40,6 +40,8 @@
|
||||
#include "shell/common/mac/main_application_bundle.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "shell/common/node_util.h"
|
||||
#include "shell/common/options_switches.h"
|
||||
#include "shell/common/platform_util.h"
|
||||
#include "shell/common/process_util.h"
|
||||
#include "shell/common/world_ids.h"
|
||||
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
|
||||
@@ -672,6 +674,19 @@ void NodeBindings::Initialize(v8::Isolate* const isolate,
|
||||
if (!fuses::IsNodeOptionsEnabled())
|
||||
process_flags |= node::ProcessInitializationFlags::kDisableNodeOptionsEnv;
|
||||
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
if (command_line->HasSwitch(switches::kNoStdioInit)) {
|
||||
process_flags |= node::ProcessInitializationFlags::kNoStdioInitialization;
|
||||
} else {
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
if (!platform_util::IsNulDeviceEnabled()) {
|
||||
LOG(FATAL) << "Unable to open nul device needed for initialization,"
|
||||
"aborting startup. As a workaround, try starting with --"
|
||||
<< switches::kNoStdioInit;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
std::shared_ptr<node::InitializationResult> result =
|
||||
node::InitializeOncePerProcess(
|
||||
args,
|
||||
|
||||
Reference in New Issue
Block a user