File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed
Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -205,13 +205,27 @@ private function findTaskRunnerProcess(): bool
205205 */
206206 private function observeTaskRunnerProcess (): bool
207207 {
208+ // since we should have remembered the PID, we can just query whether it still exists
209+ // supposedly, the PID has not rolled over yet, right...?
208210 if (OsInfo::isWindows ()) {
209- // todo Windows
210- return false ;
211+ // Windows uses GCIM to discover processes
212+ $ results = [];
213+ $ tmpPsCmd = "Get-CimInstance Win32_Process -Filter \"CommandLine LIKE '%id=\' {$ this ->lastKnownPID }\'%' \" | Select ProcessId | Format-List " ;
214+ $ status = exec ("powershell -Command $ tmpPsCmd " , $ results );
215+ if (!$ status ) {
216+ throw new RuntimeException ("Could not query whether the AsyncTask is still running. " );
217+ }
218+ // extract the PID
219+ $ echoedPid = null ;
220+ foreach ($ results as $ possiblePid ) {
221+ if ($ possiblePid == "" ) {
222+ continue ;
223+ }
224+ $ echoedPid = (int ) $ possiblePid ;
225+ }
226+ return $ this ->lastKnownPID === $ echoedPid ;
211227 }
212228 // assume anything not Windows to be Unix
213- // since we should have remembered the PID, we can just query whether it still exists
214- // supposedly, the PID has not rolled over yet, right...?
215229 $ echoedPid = exec ("ps -p {$ this ->lastKnownPID } -o pid= " );
216230 if ($ echoedPid === false ) {
217231 throw new RuntimeException ("Could not query whether the AsyncTask is still running. " );
You can’t perform that action at this time.
0 commit comments