shell: rename signal to abortSignal
this prevents accidental typos with child_process signal handling
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user