fix: enable crashpad for ELECTRON_RUN_AS_NODE processes (#36460)
* wip: enable crashpad for node processes fix: add PID testing method wip: plumb fd into child_process in node * node::ProcessInitializationFlags::kNoDefaultSignalHandling * chore: clean up debug logging * chore: gate platform includes * test: clean up node process test * fix: pass pid in node_main * chore: cleanup impl * chore: fixup patch method definition * fix: expose bound methods to node_main * fix: remove bound methods * fix: crashpad connection for all ELECTRON_RUN_AS_NODE processes * chore: fix typo * chore: address review feedback * chore: delay crashpad initialization * chore: ensure options.env, code hygiene * chore: add argv test, check for process.env over {} * fix: fix test, return options.env immutability Co-authored-by: VerteDinde <keeleymhammond@gmail.com> Co-authored-by: Jeremy Rose <jeremya@chromium.org> Co-authored-by: VerteDinde <vertedinde@electronjs.org>
This commit is contained in:
parent
16a7bd7102
commit
2c723d7e84
10 changed files with 194 additions and 12 deletions
39
shell/common/api/crashpad_support.cc
Normal file
39
shell/common/api/crashpad_support.cc
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Copyright (c) 2022 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
#include "components/crash/core/app/crashpad.h" // nogncheck
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
int GetCrashdumpSignalFD() {
|
||||
int fd;
|
||||
return crash_reporter::GetHandlerSocket(&fd, nullptr) ? fd : -1;
|
||||
}
|
||||
|
||||
int GetCrashpadHandlerPID() {
|
||||
int pid;
|
||||
return crash_reporter::GetHandlerSocket(nullptr, &pid) ? pid : -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
gin_helper::Dictionary dict(context->GetIsolate(), exports);
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
dict.SetMethod("getCrashdumpSignalFD", &GetCrashdumpSignalFD);
|
||||
dict.SetMethod("getCrashpadHandlerPID", &GetCrashpadHandlerPID);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_crashpad_support, Initialize)
|
|
@ -80,6 +80,7 @@
|
|||
V(electron_common_asar) \
|
||||
V(electron_common_clipboard) \
|
||||
V(electron_common_command_line) \
|
||||
V(electron_common_crashpad_support) \
|
||||
V(electron_common_environment) \
|
||||
V(electron_common_features) \
|
||||
V(electron_common_native_image) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue