update
This commit is contained in:
15
package/node_modules/foreground-child/LICENSE
generated
vendored
Normal file
15
package/node_modules/foreground-child/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) 2015-2023 Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
58
package/node_modules/foreground-child/dist/commonjs/all-signals.js
generated
vendored
Normal file
58
package/node_modules/foreground-child/dist/commonjs/all-signals.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.allSignals = void 0;
|
||||
const node_constants_1 = __importDefault(require("node:constants"));
|
||||
exports.allSignals =
|
||||
// this is the full list of signals that Node will let us do anything with
|
||||
Object.keys(node_constants_1.default).filter(k => k.startsWith('SIG') &&
|
||||
// https://github.com/tapjs/signal-exit/issues/21
|
||||
k !== 'SIGPROF' &&
|
||||
// no sense trying to listen for SIGKILL, it's impossible
|
||||
k !== 'SIGKILL');
|
||||
// These are some obscure signals that are reported by kill -l
|
||||
// on macOS, Linux, or Windows, but which don't have any mapping
|
||||
// in Node.js. No sense trying if they're just going to throw
|
||||
// every time on every platform.
|
||||
//
|
||||
// 'SIGEMT',
|
||||
// 'SIGLOST',
|
||||
// 'SIGPOLL',
|
||||
// 'SIGRTMAX',
|
||||
// 'SIGRTMAX-1',
|
||||
// 'SIGRTMAX-10',
|
||||
// 'SIGRTMAX-11',
|
||||
// 'SIGRTMAX-12',
|
||||
// 'SIGRTMAX-13',
|
||||
// 'SIGRTMAX-14',
|
||||
// 'SIGRTMAX-15',
|
||||
// 'SIGRTMAX-2',
|
||||
// 'SIGRTMAX-3',
|
||||
// 'SIGRTMAX-4',
|
||||
// 'SIGRTMAX-5',
|
||||
// 'SIGRTMAX-6',
|
||||
// 'SIGRTMAX-7',
|
||||
// 'SIGRTMAX-8',
|
||||
// 'SIGRTMAX-9',
|
||||
// 'SIGRTMIN',
|
||||
// 'SIGRTMIN+1',
|
||||
// 'SIGRTMIN+10',
|
||||
// 'SIGRTMIN+11',
|
||||
// 'SIGRTMIN+12',
|
||||
// 'SIGRTMIN+13',
|
||||
// 'SIGRTMIN+14',
|
||||
// 'SIGRTMIN+15',
|
||||
// 'SIGRTMIN+16',
|
||||
// 'SIGRTMIN+2',
|
||||
// 'SIGRTMIN+3',
|
||||
// 'SIGRTMIN+4',
|
||||
// 'SIGRTMIN+5',
|
||||
// 'SIGRTMIN+6',
|
||||
// 'SIGRTMIN+7',
|
||||
// 'SIGRTMIN+8',
|
||||
// 'SIGRTMIN+9',
|
||||
// 'SIGSTKFLT',
|
||||
// 'SIGUNUSED',
|
||||
//# sourceMappingURL=all-signals.js.map
|
||||
121
package/node_modules/foreground-child/dist/commonjs/index.js
generated
vendored
Normal file
121
package/node_modules/foreground-child/dist/commonjs/index.js
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.foregroundChild = exports.normalizeFgArgs = void 0;
|
||||
const child_process_1 = require("child_process");
|
||||
const cross_spawn_1 = __importDefault(require("cross-spawn"));
|
||||
const signal_exit_1 = require("signal-exit");
|
||||
const proxy_signals_js_1 = require("./proxy-signals.js");
|
||||
const watchdog_js_1 = require("./watchdog.js");
|
||||
/* c8 ignore start */
|
||||
const spawn = process?.platform === 'win32' ? cross_spawn_1.default : child_process_1.spawn;
|
||||
/**
|
||||
* Normalizes the arguments passed to `foregroundChild`.
|
||||
*
|
||||
* Exposed for testing.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
const normalizeFgArgs = (fgArgs) => {
|
||||
let [program, args = [], spawnOpts = {}, cleanup = () => { }] = fgArgs;
|
||||
if (typeof args === 'function') {
|
||||
cleanup = args;
|
||||
spawnOpts = {};
|
||||
args = [];
|
||||
}
|
||||
else if (!!args && typeof args === 'object' && !Array.isArray(args)) {
|
||||
if (typeof spawnOpts === 'function')
|
||||
cleanup = spawnOpts;
|
||||
spawnOpts = args;
|
||||
args = [];
|
||||
}
|
||||
else if (typeof spawnOpts === 'function') {
|
||||
cleanup = spawnOpts;
|
||||
spawnOpts = {};
|
||||
}
|
||||
if (Array.isArray(program)) {
|
||||
const [pp, ...pa] = program;
|
||||
program = pp;
|
||||
args = pa;
|
||||
}
|
||||
return [program, args, { ...spawnOpts }, cleanup];
|
||||
};
|
||||
exports.normalizeFgArgs = normalizeFgArgs;
|
||||
function foregroundChild(...fgArgs) {
|
||||
const [program, args, spawnOpts, cleanup] = (0, exports.normalizeFgArgs)(fgArgs);
|
||||
spawnOpts.stdio = [0, 1, 2];
|
||||
if (process.send) {
|
||||
spawnOpts.stdio.push('ipc');
|
||||
}
|
||||
const child = spawn(program, args, spawnOpts);
|
||||
const childHangup = () => {
|
||||
try {
|
||||
child.kill('SIGHUP');
|
||||
/* c8 ignore start */
|
||||
}
|
||||
catch (_) {
|
||||
// SIGHUP is weird on windows
|
||||
child.kill('SIGTERM');
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
};
|
||||
const removeOnExit = (0, signal_exit_1.onExit)(childHangup);
|
||||
(0, proxy_signals_js_1.proxySignals)(child);
|
||||
(0, watchdog_js_1.watchdog)(child);
|
||||
let done = false;
|
||||
child.on('close', async (code, signal) => {
|
||||
/* c8 ignore start */
|
||||
if (done)
|
||||
return;
|
||||
/* c8 ignore stop */
|
||||
done = true;
|
||||
const result = cleanup(code, signal);
|
||||
const res = isPromise(result) ? await result : result;
|
||||
removeOnExit();
|
||||
if (res === false)
|
||||
return;
|
||||
else if (typeof res === 'string') {
|
||||
signal = res;
|
||||
code = null;
|
||||
}
|
||||
else if (typeof res === 'number') {
|
||||
code = res;
|
||||
signal = null;
|
||||
}
|
||||
if (signal) {
|
||||
// If there is nothing else keeping the event loop alive,
|
||||
// then there's a race between a graceful exit and getting
|
||||
// the signal to this process. Put this timeout here to
|
||||
// make sure we're still alive to get the signal, and thus
|
||||
// exit with the intended signal code.
|
||||
/* istanbul ignore next */
|
||||
setTimeout(() => { }, 2000);
|
||||
try {
|
||||
process.kill(process.pid, signal);
|
||||
/* c8 ignore start */
|
||||
}
|
||||
catch (_) {
|
||||
process.kill(process.pid, 'SIGTERM');
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
}
|
||||
else {
|
||||
process.exit(code || 0);
|
||||
}
|
||||
});
|
||||
if (process.send) {
|
||||
process.removeAllListeners('message');
|
||||
child.on('message', (message, sendHandle) => {
|
||||
process.send?.(message, sendHandle);
|
||||
});
|
||||
process.on('message', (message, sendHandle) => {
|
||||
child.send(message, sendHandle);
|
||||
});
|
||||
}
|
||||
return child;
|
||||
}
|
||||
exports.foregroundChild = foregroundChild;
|
||||
const isPromise = (o) => !!o && typeof o === 'object' && typeof o.then === 'function';
|
||||
//# sourceMappingURL=index.js.map
|
||||
3
package/node_modules/foreground-child/dist/commonjs/package.json
generated
vendored
Normal file
3
package/node_modules/foreground-child/dist/commonjs/package.json
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "commonjs"
|
||||
}
|
||||
38
package/node_modules/foreground-child/dist/commonjs/proxy-signals.js
generated
vendored
Normal file
38
package/node_modules/foreground-child/dist/commonjs/proxy-signals.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.proxySignals = void 0;
|
||||
const all_signals_js_1 = require("./all-signals.js");
|
||||
/**
|
||||
* Starts forwarding signals to `child` through `parent`.
|
||||
*/
|
||||
const proxySignals = (child) => {
|
||||
const listeners = new Map();
|
||||
for (const sig of all_signals_js_1.allSignals) {
|
||||
const listener = () => {
|
||||
// some signals can only be received, not sent
|
||||
try {
|
||||
child.kill(sig);
|
||||
/* c8 ignore start */
|
||||
}
|
||||
catch (_) { }
|
||||
/* c8 ignore stop */
|
||||
};
|
||||
try {
|
||||
// if it's a signal this system doesn't recognize, skip it
|
||||
process.on(sig, listener);
|
||||
listeners.set(sig, listener);
|
||||
/* c8 ignore start */
|
||||
}
|
||||
catch (_) { }
|
||||
/* c8 ignore stop */
|
||||
}
|
||||
const unproxy = () => {
|
||||
for (const [sig, listener] of listeners) {
|
||||
process.removeListener(sig, listener);
|
||||
}
|
||||
};
|
||||
child.on('exit', unproxy);
|
||||
return unproxy;
|
||||
};
|
||||
exports.proxySignals = proxySignals;
|
||||
//# sourceMappingURL=proxy-signals.js.map
|
||||
50
package/node_modules/foreground-child/dist/commonjs/watchdog.js
generated
vendored
Normal file
50
package/node_modules/foreground-child/dist/commonjs/watchdog.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
// this spawns a child process that listens for SIGHUP when the
|
||||
// parent process exits, and after 200ms, sends a SIGKILL to the
|
||||
// child, in case it did not terminate.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.watchdog = void 0;
|
||||
const child_process_1 = require("child_process");
|
||||
const watchdogCode = String.raw `
|
||||
const pid = parseInt(process.argv[1], 10)
|
||||
process.title = 'node (foreground-child watchdog pid=' + pid + ')'
|
||||
if (!isNaN(pid)) {
|
||||
let barked = false
|
||||
// keepalive
|
||||
const interval = setInterval(() => {}, 60000)
|
||||
const bark = () => {
|
||||
clearInterval(interval)
|
||||
if (barked) return
|
||||
barked = true
|
||||
process.removeListener('SIGHUP', bark)
|
||||
setTimeout(() => {
|
||||
try {
|
||||
process.kill(pid, 'SIGKILL')
|
||||
setTimeout(() => process.exit(), 200)
|
||||
} catch (_) {}
|
||||
}, 500)
|
||||
})
|
||||
process.on('SIGHUP', bark)
|
||||
}
|
||||
`;
|
||||
/**
|
||||
* Pass in a ChildProcess, and this will spawn a watchdog process that
|
||||
* will make sure it exits if the parent does, thus preventing any
|
||||
* dangling detached zombie processes.
|
||||
*
|
||||
* If the child ends before the parent, then the watchdog will terminate.
|
||||
*/
|
||||
const watchdog = (child) => {
|
||||
let dogExited = false;
|
||||
const dog = (0, child_process_1.spawn)(process.execPath, ['-e', watchdogCode, String(child.pid)], {
|
||||
stdio: 'ignore',
|
||||
});
|
||||
dog.on('exit', () => (dogExited = true));
|
||||
child.on('exit', () => {
|
||||
if (!dogExited)
|
||||
dog.kill('SIGKILL');
|
||||
});
|
||||
return dog;
|
||||
};
|
||||
exports.watchdog = watchdog;
|
||||
//# sourceMappingURL=watchdog.js.map
|
||||
52
package/node_modules/foreground-child/dist/esm/all-signals.js
generated
vendored
Normal file
52
package/node_modules/foreground-child/dist/esm/all-signals.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
import constants from 'node:constants';
|
||||
export const allSignals =
|
||||
// this is the full list of signals that Node will let us do anything with
|
||||
Object.keys(constants).filter(k => k.startsWith('SIG') &&
|
||||
// https://github.com/tapjs/signal-exit/issues/21
|
||||
k !== 'SIGPROF' &&
|
||||
// no sense trying to listen for SIGKILL, it's impossible
|
||||
k !== 'SIGKILL');
|
||||
// These are some obscure signals that are reported by kill -l
|
||||
// on macOS, Linux, or Windows, but which don't have any mapping
|
||||
// in Node.js. No sense trying if they're just going to throw
|
||||
// every time on every platform.
|
||||
//
|
||||
// 'SIGEMT',
|
||||
// 'SIGLOST',
|
||||
// 'SIGPOLL',
|
||||
// 'SIGRTMAX',
|
||||
// 'SIGRTMAX-1',
|
||||
// 'SIGRTMAX-10',
|
||||
// 'SIGRTMAX-11',
|
||||
// 'SIGRTMAX-12',
|
||||
// 'SIGRTMAX-13',
|
||||
// 'SIGRTMAX-14',
|
||||
// 'SIGRTMAX-15',
|
||||
// 'SIGRTMAX-2',
|
||||
// 'SIGRTMAX-3',
|
||||
// 'SIGRTMAX-4',
|
||||
// 'SIGRTMAX-5',
|
||||
// 'SIGRTMAX-6',
|
||||
// 'SIGRTMAX-7',
|
||||
// 'SIGRTMAX-8',
|
||||
// 'SIGRTMAX-9',
|
||||
// 'SIGRTMIN',
|
||||
// 'SIGRTMIN+1',
|
||||
// 'SIGRTMIN+10',
|
||||
// 'SIGRTMIN+11',
|
||||
// 'SIGRTMIN+12',
|
||||
// 'SIGRTMIN+13',
|
||||
// 'SIGRTMIN+14',
|
||||
// 'SIGRTMIN+15',
|
||||
// 'SIGRTMIN+16',
|
||||
// 'SIGRTMIN+2',
|
||||
// 'SIGRTMIN+3',
|
||||
// 'SIGRTMIN+4',
|
||||
// 'SIGRTMIN+5',
|
||||
// 'SIGRTMIN+6',
|
||||
// 'SIGRTMIN+7',
|
||||
// 'SIGRTMIN+8',
|
||||
// 'SIGRTMIN+9',
|
||||
// 'SIGSTKFLT',
|
||||
// 'SIGUNUSED',
|
||||
//# sourceMappingURL=all-signals.js.map
|
||||
113
package/node_modules/foreground-child/dist/esm/index.js
generated
vendored
Normal file
113
package/node_modules/foreground-child/dist/esm/index.js
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
import { spawn as nodeSpawn, } from 'child_process';
|
||||
import crossSpawn from 'cross-spawn';
|
||||
import { onExit } from 'signal-exit';
|
||||
import { proxySignals } from './proxy-signals.js';
|
||||
import { watchdog } from './watchdog.js';
|
||||
/* c8 ignore start */
|
||||
const spawn = process?.platform === 'win32' ? crossSpawn : nodeSpawn;
|
||||
/**
|
||||
* Normalizes the arguments passed to `foregroundChild`.
|
||||
*
|
||||
* Exposed for testing.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const normalizeFgArgs = (fgArgs) => {
|
||||
let [program, args = [], spawnOpts = {}, cleanup = () => { }] = fgArgs;
|
||||
if (typeof args === 'function') {
|
||||
cleanup = args;
|
||||
spawnOpts = {};
|
||||
args = [];
|
||||
}
|
||||
else if (!!args && typeof args === 'object' && !Array.isArray(args)) {
|
||||
if (typeof spawnOpts === 'function')
|
||||
cleanup = spawnOpts;
|
||||
spawnOpts = args;
|
||||
args = [];
|
||||
}
|
||||
else if (typeof spawnOpts === 'function') {
|
||||
cleanup = spawnOpts;
|
||||
spawnOpts = {};
|
||||
}
|
||||
if (Array.isArray(program)) {
|
||||
const [pp, ...pa] = program;
|
||||
program = pp;
|
||||
args = pa;
|
||||
}
|
||||
return [program, args, { ...spawnOpts }, cleanup];
|
||||
};
|
||||
export function foregroundChild(...fgArgs) {
|
||||
const [program, args, spawnOpts, cleanup] = normalizeFgArgs(fgArgs);
|
||||
spawnOpts.stdio = [0, 1, 2];
|
||||
if (process.send) {
|
||||
spawnOpts.stdio.push('ipc');
|
||||
}
|
||||
const child = spawn(program, args, spawnOpts);
|
||||
const childHangup = () => {
|
||||
try {
|
||||
child.kill('SIGHUP');
|
||||
/* c8 ignore start */
|
||||
}
|
||||
catch (_) {
|
||||
// SIGHUP is weird on windows
|
||||
child.kill('SIGTERM');
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
};
|
||||
const removeOnExit = onExit(childHangup);
|
||||
proxySignals(child);
|
||||
watchdog(child);
|
||||
let done = false;
|
||||
child.on('close', async (code, signal) => {
|
||||
/* c8 ignore start */
|
||||
if (done)
|
||||
return;
|
||||
/* c8 ignore stop */
|
||||
done = true;
|
||||
const result = cleanup(code, signal);
|
||||
const res = isPromise(result) ? await result : result;
|
||||
removeOnExit();
|
||||
if (res === false)
|
||||
return;
|
||||
else if (typeof res === 'string') {
|
||||
signal = res;
|
||||
code = null;
|
||||
}
|
||||
else if (typeof res === 'number') {
|
||||
code = res;
|
||||
signal = null;
|
||||
}
|
||||
if (signal) {
|
||||
// If there is nothing else keeping the event loop alive,
|
||||
// then there's a race between a graceful exit and getting
|
||||
// the signal to this process. Put this timeout here to
|
||||
// make sure we're still alive to get the signal, and thus
|
||||
// exit with the intended signal code.
|
||||
/* istanbul ignore next */
|
||||
setTimeout(() => { }, 2000);
|
||||
try {
|
||||
process.kill(process.pid, signal);
|
||||
/* c8 ignore start */
|
||||
}
|
||||
catch (_) {
|
||||
process.kill(process.pid, 'SIGTERM');
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
}
|
||||
else {
|
||||
process.exit(code || 0);
|
||||
}
|
||||
});
|
||||
if (process.send) {
|
||||
process.removeAllListeners('message');
|
||||
child.on('message', (message, sendHandle) => {
|
||||
process.send?.(message, sendHandle);
|
||||
});
|
||||
process.on('message', (message, sendHandle) => {
|
||||
child.send(message, sendHandle);
|
||||
});
|
||||
}
|
||||
return child;
|
||||
}
|
||||
const isPromise = (o) => !!o && typeof o === 'object' && typeof o.then === 'function';
|
||||
//# sourceMappingURL=index.js.map
|
||||
3
package/node_modules/foreground-child/dist/esm/package.json
generated
vendored
Normal file
3
package/node_modules/foreground-child/dist/esm/package.json
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
34
package/node_modules/foreground-child/dist/esm/proxy-signals.js
generated
vendored
Normal file
34
package/node_modules/foreground-child/dist/esm/proxy-signals.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import { allSignals } from './all-signals.js';
|
||||
/**
|
||||
* Starts forwarding signals to `child` through `parent`.
|
||||
*/
|
||||
export const proxySignals = (child) => {
|
||||
const listeners = new Map();
|
||||
for (const sig of allSignals) {
|
||||
const listener = () => {
|
||||
// some signals can only be received, not sent
|
||||
try {
|
||||
child.kill(sig);
|
||||
/* c8 ignore start */
|
||||
}
|
||||
catch (_) { }
|
||||
/* c8 ignore stop */
|
||||
};
|
||||
try {
|
||||
// if it's a signal this system doesn't recognize, skip it
|
||||
process.on(sig, listener);
|
||||
listeners.set(sig, listener);
|
||||
/* c8 ignore start */
|
||||
}
|
||||
catch (_) { }
|
||||
/* c8 ignore stop */
|
||||
}
|
||||
const unproxy = () => {
|
||||
for (const [sig, listener] of listeners) {
|
||||
process.removeListener(sig, listener);
|
||||
}
|
||||
};
|
||||
child.on('exit', unproxy);
|
||||
return unproxy;
|
||||
};
|
||||
//# sourceMappingURL=proxy-signals.js.map
|
||||
46
package/node_modules/foreground-child/dist/esm/watchdog.js
generated
vendored
Normal file
46
package/node_modules/foreground-child/dist/esm/watchdog.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
// this spawns a child process that listens for SIGHUP when the
|
||||
// parent process exits, and after 200ms, sends a SIGKILL to the
|
||||
// child, in case it did not terminate.
|
||||
import { spawn } from 'child_process';
|
||||
const watchdogCode = String.raw `
|
||||
const pid = parseInt(process.argv[1], 10)
|
||||
process.title = 'node (foreground-child watchdog pid=' + pid + ')'
|
||||
if (!isNaN(pid)) {
|
||||
let barked = false
|
||||
// keepalive
|
||||
const interval = setInterval(() => {}, 60000)
|
||||
const bark = () => {
|
||||
clearInterval(interval)
|
||||
if (barked) return
|
||||
barked = true
|
||||
process.removeListener('SIGHUP', bark)
|
||||
setTimeout(() => {
|
||||
try {
|
||||
process.kill(pid, 'SIGKILL')
|
||||
setTimeout(() => process.exit(), 200)
|
||||
} catch (_) {}
|
||||
}, 500)
|
||||
})
|
||||
process.on('SIGHUP', bark)
|
||||
}
|
||||
`;
|
||||
/**
|
||||
* Pass in a ChildProcess, and this will spawn a watchdog process that
|
||||
* will make sure it exits if the parent does, thus preventing any
|
||||
* dangling detached zombie processes.
|
||||
*
|
||||
* If the child ends before the parent, then the watchdog will terminate.
|
||||
*/
|
||||
export const watchdog = (child) => {
|
||||
let dogExited = false;
|
||||
const dog = spawn(process.execPath, ['-e', watchdogCode, String(child.pid)], {
|
||||
stdio: 'ignore',
|
||||
});
|
||||
dog.on('exit', () => (dogExited = true));
|
||||
child.on('exit', () => {
|
||||
if (!dogExited)
|
||||
dog.kill('SIGKILL');
|
||||
});
|
||||
return dog;
|
||||
};
|
||||
//# sourceMappingURL=watchdog.js.map
|
||||
111
package/node_modules/foreground-child/package.json
generated
vendored
Normal file
111
package/node_modules/foreground-child/package.json
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
{
|
||||
"name": "foreground-child",
|
||||
"version": "3.2.1",
|
||||
"description": "Run a child as if it's the foreground process. Give it stdio. Exit when it exits.",
|
||||
"main": "./dist/commonjs/index.js",
|
||||
"types": "./dist/commonjs/index.d.ts",
|
||||
"exports": {
|
||||
"./watchdog": {
|
||||
"import": {
|
||||
"source": "./src/watchdog.ts",
|
||||
"types": "./dist/esm/watchdog.d.ts",
|
||||
"default": "./dist/esm/watchdog.js"
|
||||
},
|
||||
"require": {
|
||||
"source": "./src/watchdog.ts",
|
||||
"types": "./dist/commonjs/watchdog.d.ts",
|
||||
"default": "./dist/commonjs/watchdog.js"
|
||||
}
|
||||
},
|
||||
"./proxy-signals": {
|
||||
"import": {
|
||||
"source": "./src/proxy-signals.ts",
|
||||
"types": "./dist/esm/proxy-signals.d.ts",
|
||||
"default": "./dist/esm/proxy-signals.js"
|
||||
},
|
||||
"require": {
|
||||
"source": "./src/proxy-signals.ts",
|
||||
"types": "./dist/commonjs/proxy-signals.d.ts",
|
||||
"default": "./dist/commonjs/proxy-signals.js"
|
||||
}
|
||||
},
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"import": {
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"default": "./dist/esm/index.js"
|
||||
},
|
||||
"require": {
|
||||
"source": "./src/index.ts",
|
||||
"types": "./dist/commonjs/index.d.ts",
|
||||
"default": "./dist/commonjs/index.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"dependencies": {
|
||||
"cross-spawn": "^7.0.0",
|
||||
"signal-exit": "^4.0.1"
|
||||
},
|
||||
"scripts": {
|
||||
"preversion": "npm test",
|
||||
"postversion": "npm publish",
|
||||
"prepublishOnly": "git push origin --follow-tags",
|
||||
"prepare": "tshy",
|
||||
"pretest": "npm run prepare",
|
||||
"presnap": "npm run prepare",
|
||||
"test": "tap",
|
||||
"snap": "tap",
|
||||
"format": "prettier --write . --log-level warn",
|
||||
"typedoc": "typedoc --tsconfig .tshy/esm.json ./src/*.ts"
|
||||
},
|
||||
"prettier": {
|
||||
"experimentalTernaries": true,
|
||||
"semi": false,
|
||||
"printWidth": 75,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"singleQuote": true,
|
||||
"jsxSingleQuote": false,
|
||||
"bracketSameLine": true,
|
||||
"arrowParens": "avoid",
|
||||
"endOfLine": "lf"
|
||||
},
|
||||
"tap": {
|
||||
"typecheck": true
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/tapjs/foreground-child.git"
|
||||
},
|
||||
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@types/cross-spawn": "^6.0.2",
|
||||
"@types/node": "^18.15.11",
|
||||
"@types/tap": "^15.0.8",
|
||||
"prettier": "^3.3.2",
|
||||
"tap": "^19.2.5",
|
||||
"tshy": "^1.15.1",
|
||||
"typedoc": "^0.24.2",
|
||||
"typescript": "^5.0.2"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
},
|
||||
"tshy": {
|
||||
"exports": {
|
||||
"./watchdog": "./src/watchdog.ts",
|
||||
"./proxy-signals": "./src/proxy-signals.ts",
|
||||
"./package.json": "./package.json",
|
||||
".": "./src/index.ts"
|
||||
}
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
Reference in New Issue
Block a user