mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: kill browser process when 'taskkill' fails on Windows (#8352)
This commit is contained in:
parent
24dfbd5f7f
commit
dccfadb90e
@ -186,7 +186,14 @@ export class BrowserRunner {
|
||||
if (this.proc && this.proc.pid && pidExists(this.proc.pid)) {
|
||||
try {
|
||||
if (process.platform === 'win32') {
|
||||
childProcess.exec(`taskkill /pid ${this.proc.pid} /T /F`, () => {});
|
||||
childProcess.exec(`taskkill /pid ${this.proc.pid} /T /F`, (error) => {
|
||||
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.
|
||||
this.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.
|
||||
|
Loading…
Reference in New Issue
Block a user