123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
- From: VerteDinde <[email protected]>
- 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
- index bb27670112c1ea42c7ff00883fe4b684544d9cd4..4d4da798ce59ce42e42d1f05fccf07699c033d46 100644
- --- a/lib/child_process.js
- +++ b/lib/child_process.js
- @@ -61,6 +61,7 @@ let debug = require('internal/util/debuglog').debuglog(
- );
- const { Buffer } = require('buffer');
- const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap');
- +const { getCrashdumpSignalFD, getCrashpadHandlerPID } = process._linkedBinding('electron_common_crashpad_support');
-
- const {
- AbortError,
- @@ -153,7 +154,6 @@ function fork(modulePath, args = [], options) {
- ArrayPrototypeSplice(execArgv, index - 1, 2);
- }
- }
- -
- args = [...execArgv, modulePath, ...args];
-
- if (typeof options.stdio === 'string') {
- @@ -609,6 +609,22 @@ function normalizeSpawnArguments(file, args, options) {
- 'options.windowsVerbatimArguments');
- }
-
- + 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;
- + }
- + }
- +
- if (options.shell) {
- validateArgumentNullCheck(options.shell, 'options.shell');
- const command = ArrayPrototypeJoin([file, ...args], ' ');
- @@ -642,7 +658,6 @@ function normalizeSpawnArguments(file, args, options) {
- ArrayPrototypeUnshift(args, file);
- }
-
- - const env = options.env || process.env;
- const envPairs = [];
-
- // process.env.NODE_V8_COVERAGE always propagates, making it possible to
|