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

Commit e85978f

Browse files
committed
PR feedback
1 parent f081f7e commit e85978f

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/chromeDebugAdapter.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,14 +342,21 @@ export class ChromeDebugAdapter extends CoreDebugAdapter {
342342
}
343343

344344
for (let i = 0 ; i < 10; i++) {
345-
// Check to see if the process is still running
346-
let tasklistOutput = execSync(`tasklist /FI "PID eq ${chromePID}"`).toString();
347-
if (!tasklistOutput.includes(chromePID.toString())) {
345+
// Check to see if the process is still running, with CSV output format
346+
let tasklistCmd = `tasklist /FI "PID eq ${chromePID}" /FO CSV`;
347+
logger.log(`Looking up process by pid: ${tasklistCmd}`);
348+
let tasklistOutput = execSync(tasklistCmd).toString();
349+
350+
// If the process is found, tasklist will output CSV with one of the values being the PID. Exit code will be 0.
351+
// If the process is not found, tasklist will give a generic "not found" message instead. Exit code will also be 0.
352+
// If we see an entry in the CSV for the PID, then we can assume the process was found.
353+
if (!tasklistOutput.includes(`"${chromePID}"`)) {
354+
logger.log(`Chrome process with pid ${chromePID} is not running`);
348355
return;
349356
}
350357

351358
// Give the process some time to close gracefully
352-
logger.log(`Chrome process with pid ${chromePID} is still alive, waiting...`)
359+
logger.log(`Chrome process with pid ${chromePID} is still alive, waiting...`);
353360
await new Promise<void>((resolve) => {
354361
setTimeout(resolve, 200);
355362
});

0 commit comments

Comments
 (0)