2022-11-29 15:33:54 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: VerteDinde <keeleymhammond@gmail.com>
|
|
|
|
Date: Sun, 20 Nov 2022 21:45:20 -0800
|
|
|
|
Subject: fix: enable crashpad for ELECTRON_RUN_AS_NODE linux processes
|
|
|
|
|
|
|
|
Passes the crashpad handler PID and crashdump signal file descriptor
|
|
|
|
to child processes spawned with `ELECTRON_RUN_AS_NODE` which is used
|
|
|
|
by the crashpad client to connect with the handler process.
|
|
|
|
|
|
|
|
diff --git a/lib/child_process.js b/lib/child_process.js
|
2024-08-27 19:03:21 +00:00
|
|
|
index 48870b35ad0f3411f2d509b12d92a9e0d20046f9..e7ef454d2d71207ae7b2788a437b82bf7732716e 100644
|
2022-11-29 15:33:54 +00:00
|
|
|
--- a/lib/child_process.js
|
|
|
|
+++ b/lib/child_process.js
|
2023-09-20 20:13:43 +00:00
|
|
|
@@ -61,6 +61,7 @@ let debug = require('internal/util/debuglog').debuglog(
|
2022-11-29 15:33:54 +00:00
|
|
|
);
|
|
|
|
const { Buffer } = require('buffer');
|
|
|
|
const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap');
|
|
|
|
+const { getCrashdumpSignalFD, getCrashpadHandlerPID } = process._linkedBinding('electron_common_crashpad_support');
|
|
|
|
|
|
|
|
const {
|
|
|
|
AbortError,
|
2024-01-24 15:54:32 +00:00
|
|
|
@@ -154,7 +155,6 @@ function fork(modulePath, args = [], options) {
|
2022-11-29 15:33:54 +00:00
|
|
|
ArrayPrototypeSplice(execArgv, index - 1, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-
|
|
|
|
args = [...execArgv, modulePath, ...args];
|
|
|
|
|
|
|
|
if (typeof options.stdio === 'string') {
|
2024-08-27 19:03:21 +00:00
|
|
|
@@ -618,6 +618,22 @@ function normalizeSpawnArguments(file, args, options) {
|
2022-11-29 15:33:54 +00:00
|
|
|
'options.windowsVerbatimArguments');
|
|
|
|
}
|
|
|
|
|
2024-05-27 08:41:42 +00:00
|
|
|
+ const env = options.env || process.env;
|
|
|
|
+
|
|
|
|
+ if ((process.platform === 'linux') &&
|
|
|
|
+ ObjectPrototypeHasOwnProperty(env, 'ELECTRON_RUN_AS_NODE') &&
|
|
|
|
+ (file === process.execPath)) {
|
|
|
|
+ // On Linux, pass the file descriptor which crashpad handler process
|
|
|
|
+ // uses to monitor the child process and PID of the handler process.
|
|
|
|
+ // https://source.chromium.org/chromium/chromium/src/+/110.0.5415.0:components/crash/core/app/crashpad_linux.cc;l=199-206
|
|
|
|
+ const fd = getCrashdumpSignalFD();
|
|
|
|
+ const pid = getCrashpadHandlerPID();
|
|
|
|
+ if (fd !== -1 && pid !== -1) {
|
|
|
|
+ env.CRASHDUMP_SIGNAL_FD = fd;
|
|
|
|
+ env.CRASHPAD_HANDLER_PID = pid;
|
2022-11-29 15:33:54 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
if (options.shell) {
|
2023-01-11 10:33:48 +00:00
|
|
|
validateArgumentNullCheck(options.shell, 'options.shell');
|
2022-11-29 15:33:54 +00:00
|
|
|
const command = ArrayPrototypeJoin([file, ...args], ' ');
|
2024-08-27 19:03:21 +00:00
|
|
|
@@ -651,7 +667,6 @@ function normalizeSpawnArguments(file, args, options) {
|
2024-05-27 08:41:42 +00:00
|
|
|
ArrayPrototypeUnshift(args, file);
|
|
|
|
}
|
|
|
|
|
|
|
|
- const env = options.env || process.env;
|
|
|
|
const envPairs = [];
|
|
|
|
|
|
|
|
// process.env.NODE_V8_COVERAGE always propagates, making it possible to
|