Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcrane committed Jul 18, 2018
1 parent f081f7e commit e85978f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/chromeDebugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,21 @@ export class ChromeDebugAdapter extends CoreDebugAdapter {
}

for (let i = 0 ; i < 10; i++) {
// Check to see if the process is still running
let tasklistOutput = execSync(`tasklist /FI "PID eq ${chromePID}"`).toString();
if (!tasklistOutput.includes(chromePID.toString())) {
// Check to see if the process is still running, with CSV output format
let tasklistCmd = `tasklist /FI "PID eq ${chromePID}" /FO CSV`;
logger.log(`Looking up process by pid: ${tasklistCmd}`);
let tasklistOutput = execSync(tasklistCmd).toString();

// If the process is found, tasklist will output CSV with one of the values being the PID. Exit code will be 0.
// If the process is not found, tasklist will give a generic "not found" message instead. Exit code will also be 0.
// If we see an entry in the CSV for the PID, then we can assume the process was found.
if (!tasklistOutput.includes(`"${chromePID}"`)) {
logger.log(`Chrome process with pid ${chromePID} is not running`);
return;
}

// Give the process some time to close gracefully
logger.log(`Chrome process with pid ${chromePID} is still alive, waiting...`)
logger.log(`Chrome process with pid ${chromePID} is still alive, waiting...`);
await new Promise<void>((resolve) => {
setTimeout(resolve, 200);
});
Expand Down

0 comments on commit e85978f

Please sign in to comment.