Skip to content

Commit

Permalink
Merge pull request #123895 from danielgary/wmic-replacement
Browse files Browse the repository at this point in the history
Replaced wmic call with windows-process-tree
  • Loading branch information
weinand committed May 18, 2021
2 parents 615bb08 + 09b77ba commit 026e623
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/vs/workbench/contrib/debug/node/terminals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { ExtHostConfigProvider } from 'vs/workbench/api/common/extHostConfiguration';



function spawnAsPromised(command: string, args: string[]): Promise<string> {
return new Promise((resolve, reject) => {
let stdout = '';
Expand Down Expand Up @@ -50,13 +51,15 @@ export function runInExternalTerminal(args: DebugProtocol.RunInTerminalRequestAr

export function hasChildProcesses(processId: number | undefined): Promise<boolean> {
if (processId) {

// if shell has at least one child process, assume that shell is busy
if (platform.isWindows) {
return spawnAsPromised('wmic', ['process', 'get', 'ParentProcessId']).then(stdout => {
const pids = stdout.split('\r\n');
return pids.some(p => parseInt(p) === processId);
}, error => {
return true;
return new Promise<boolean>(async (resolve) => {
// See #123296
const windowsProcessTree = await import('windows-process-tree');
windowsProcessTree.getProcessTree(processId, (processTree) => {
resolve(processTree.children.length > 0);
});
});
} else {
return spawnAsPromised('/usr/bin/pgrep', ['-lP', String(processId)]).then(stdout => {
Expand Down

0 comments on commit 026e623

Please sign in to comment.