Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced wmic call with windows-process-tree #123895

Merged
merged 2 commits into from
May 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/vs/workbench/contrib/debug/node/terminals.ts
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