Skip to content

Commit

Permalink
fix hanging on stopProcess() for daemon or wallet if already terminated
Browse files Browse the repository at this point in the history
  • Loading branch information
woodser committed May 26, 2023
1 parent b06673a commit 5afa384
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/js/common/GenUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1500,10 +1500,14 @@ class GenUtils {
* @return {Promise<number|undefined>} the exit code from killing the process
*/
static async killProcess(process, signal) {
return new Promise(function(resolve, reject) {
return new Promise((resolve, reject) => {
process.on("exit", function(code, signal) { resolve(code); });
process.on("error", function(err) { reject(err); });
process.kill(signal ? signal : "SIGINT");
try {
if (!process.kill(signal ? signal : "SIGINT")) resolve(); // resolve immediately if not running
} catch (err) {
reject(err);
}
});
}
}
Expand Down

0 comments on commit 5afa384

Please sign in to comment.