Skip to content

Commit 547ed63

Browse files
use process.kill for all platforms and early return if already killed
1 parent b4c6878 commit 547ed63

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/libraries/Executor.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,10 @@ class Executor {
3636
}
3737

3838
async #killProcess(process: ChildProcess): Promise<boolean> {
39-
let killed = false;
40-
if (os.platform() === 'win32') {
41-
const {error, stderr} = await this.#executeFile('taskkill', ['/pid', String(process.pid), '/t', '/f'])
42-
if (!error && !stderr) {
43-
killed = true;
44-
} else {
45-
this.logger.error(error || stderr)
46-
}
47-
} else {
48-
killed = process.kill()
49-
}
50-
return killed;
39+
// If the process has already been killed, return true
40+
if (process.kill(0) === false) return true
41+
42+
return process.kill()
5143
}
5244

5345
//Returns a path to the binary if it should be deleted

0 commit comments

Comments
 (0)