This repository was archived by the owner on Dec 6, 2022. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 } ) ;
You can’t perform that action at this time.
0 commit comments