Skip to content

Commit e7a6330

Browse files
committed
Allow process.kill to fail with ESRCH
1 parent 4b41574 commit e7a6330

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/DenoWorker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ export class DenoWorker {
420420
}
421421

422422
/**
423-
* Terminiates the worker and cleans up unused resources.
423+
* Terminates the worker and cleans up unused resources.
424424
*/
425425
terminate() {
426426
this._terminated = true;

src/Utils.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,18 @@ function killWindows(pid: number) {
2929
}
3030

3131
function killUnix(pid: number) {
32-
const signal = 'SIGKILL';
33-
process.kill(pid, signal);
32+
try {
33+
const signal = 'SIGKILL';
34+
process.kill(pid, signal);
35+
} catch (e) {
36+
// Allow this call to fail with
37+
// ESRCH, which meant that the process
38+
// to be killed was already dead.
39+
// But re-throw on other codes.
40+
if (e.code !== 'ESRCH') {
41+
throw e;
42+
}
43+
}
3444
}
3545

3646
export interface ExecResult {

0 commit comments

Comments
 (0)