From ca985dd2cb7de09583d74359f7ac3e6f50e78b97 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Thu, 12 Oct 2023 20:21:49 -0600 Subject: [PATCH] Fix onExit(): emits a object containing exitCode and signal --- core/archive_util.js | 10 +++++----- core/door.js | 12 +++++++----- core/event_scheduler.js | 12 ++++++------ core/file_transfer.js | 5 +++-- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/core/archive_util.js b/core/archive_util.js index 5f1eff31..ef9a00fc 100644 --- a/core/archive_util.js +++ b/core/archive_util.js @@ -214,11 +214,11 @@ module.exports = class ArchiveUtil { } }); - proc.onExit(exitCode => { + proc.onExit(exitEvent => { return cb( exitCode ? Errors.ExternalProcess( - `${action} failed with exit code: ${exitCode}` + `${action} failed with exit code: ${exitEvent.exitCode}` ) : err ); @@ -358,10 +358,10 @@ module.exports = class ArchiveUtil { output += data; }); - proc.onExit(exitCode => { - if (exitCode) { + proc.onExit(exitEvent => { + if (exitEvent.exitCode) { return cb( - Errors.ExternalProcess(`List failed with exit code: ${exitCode}`) + Errors.ExternalProcess(`List failed with exit code: ${exitEvent.exitCode}`) ); } diff --git a/core/door.js b/core/door.js index 3cab2b36..fde6c2b7 100644 --- a/core/door.js +++ b/core/door.js @@ -113,9 +113,10 @@ module.exports = class Door { spawnOptions ); - prePty.onExit(exitCode => { + prePty.onExit(exitEvent => { + const {exitCode, signal} = exitEvent; this.client.log.info( - { exitCode: exitCode }, + { exitCode, signal }, 'Door pre-command exited' ); return callback(null); @@ -165,7 +166,7 @@ module.exports = class Door { this.doorPty.onData(this.doorDataHandler.bind(this)); - this.doorPty.onExit(exitCode => { + this.doorPty.onExit( (/*exitEvent*/) => { return this.restoreIo(this.doorPty); }); } else if ('socket' === this.io) { @@ -178,8 +179,9 @@ module.exports = class Door { ); } - this.doorPty.onExit(exitCode => { - this.client.log.info({ exitCode: exitCode }, 'Door exited'); + this.doorPty.onExit(exitEvent => { + const {exitCode, signal} = exitEvent; + this.client.log.info({ exitCode, signal }, 'Door exited'); if (this.sockServer) { this.sockServer.close(); diff --git a/core/event_scheduler.js b/core/event_scheduler.js index 0140a776..798af46b 100644 --- a/core/event_scheduler.js +++ b/core/event_scheduler.js @@ -166,18 +166,18 @@ class ScheduledEvent { }); return cb(e); } - - proc.onExit(exitCode => { - if (exitCode) { + + proc.onExit(exitEvent => { + if (exitEvent.exitCode) { Log.warn( - { eventName: this.name, action: this.action, exitCode: exitCode }, + { eventName: this.name, action: this.action, exitCode: exitEvent.exitCode }, 'Bad exit code while performing scheduled event action' ); } return cb( - exitCode + exitEvent.exitCode ? Errors.ExternalProcess( - `Bad exit code while performing scheduled event action: ${exitCode}` + `Bad exit code while performing scheduled event action: ${exitEvent.exitCode}` ) : null ); diff --git a/core/file_transfer.js b/core/file_transfer.js index 264bb97d..0feb53ea 100644 --- a/core/file_transfer.js +++ b/core/file_transfer.js @@ -485,9 +485,10 @@ exports.getModule = class TransferFileModule extends MenuModule { } }); - externalProc.onExit(exitCode => { + externalProc.onExit(exitEvent => { + const {exitCode, signal} = exitEvent; this.client.log.debug( - { cmd: cmd, args: args, exitCode: exitCode }, + { cmd: cmd, args: args, exitCode, signal }, 'Process exited' );