shell: rename signal to abortSignal

this prevents accidental typos with child_process signal handling
This commit is contained in:
Girish Ramakrishnan
2025-07-17 09:50:43 +02:00
parent 38032f0b77
commit 5e1c32b606
3 changed files with 16 additions and 12 deletions

View File

@@ -45,10 +45,10 @@ function spawn(tag, file, args, options) {
const maxLines = options.maxLines || Number.MAX_SAFE_INTEGER;
const logger = options.logger || null;
const signal = options.signal || null; // note: we use our own handler and not the child_process one
const abortSignal = options.abortSignal || null; // note: we use our own handler and not the child_process one
return new Promise((resolve, reject) => {
const spawnOptions = _.omit(options, [ 'maxLines', 'logger', 'signal', 'onMessage', 'input', 'encoding' ]);
const spawnOptions = _.omit(options, [ 'maxLines', 'logger', 'abortSignal', 'onMessage', 'input', 'encoding' ]);
const cp = child_process.spawn(file, args, spawnOptions);
const stdoutBuffers = [], stderrBuffers = [];
let stdoutLineCount = 0, stderrLineCount = 0;
@@ -91,7 +91,7 @@ function spawn(tag, file, args, options) {
debug(`${tag}: ${file} ${args.join(' ').replace(/\n/g, '\\n')} errored`, error);
});
signal?.addEventListener('abort', () => {
abortSignal?.addEventListener('abort', () => {
debug(`${tag}: aborting ${cp.pid}`);
child_process.execFile('/usr/bin/sudo', [ KILL_CHILD_CMD, cp.pid, process.pid ], { encoding: 'utf8' }, (error, stdout, stderr) => {
if (error) debug(`${tag}: failed to kill children`, stdout, stderr);