Skip to content

Commit

Permalink
fix: Kill browser process when killing process group fails
Browse files Browse the repository at this point in the history
Fixes #8476. Similar fix to #8352 which only covered Windows.
  • Loading branch information
jimmydief committed Jun 6, 2022
1 parent 1b025b4 commit efc538d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/node/BrowserRunner.ts
Expand Up @@ -195,15 +195,23 @@ export class BrowserRunner {
if (error) {
// taskkill can fail to kill the process e.g. due to missing permissions.
// Let's kill the process via Node API. This delays killing of all child
// proccesses of `this.proc` until the main Node.js process dies.
// processes of `this.proc` until the main Node.js process dies.
proc.kill();
}
});
} else {
// on linux the process group can be killed with the group id prefixed with
// a minus sign. The process group id is the group leader's pid.
const processGroupId = -this.proc.pid;
process.kill(processGroupId, 'SIGKILL');

try {
process.kill(processGroupId, 'SIGKILL');
} catch (error) {
// Killing the process group can fail due e.g. to missing permissions.
// Let's kill the process via Node API. This delays killing of all child
// processes of `this.proc` until the main Node.js process dies.
proc.kill();
}
}
} catch (error) {
throw new Error(
Expand Down

0 comments on commit efc538d

Please sign in to comment.