Skip to content

Commit 62c0b6d

Browse files
atsamd21woodser
authored andcommitted
Check if process is running before killing
1 parent 5b233a2 commit 62c0b6d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/utils/HavenoUtils.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,12 @@ export default class HavenoUtils {
9191
process.on("error", function(err: any) { reject(err); });
9292

9393
if (global.process.platform === 'win32') {
94-
exec(`taskkill /PID ${process.pid} /T /F`, err => {
95-
if (err) reject(err);
94+
exec(`tasklist /FI "PID eq ${process.pid}"`, (err, stdout) => {
95+
if (stdout.includes(process.pid.toString())) {
96+
exec(`taskkill /PID ${process.pid} /T /F`, err => {
97+
if (err) reject(err);
98+
});
99+
}
96100
});
97101
} else {
98102
process.kill(signal ? signal : "SIGINT");

0 commit comments

Comments
 (0)