diff --git a/package.json b/package.json index 2339b0f7cbb..17b5ee8a4df 100644 --- a/package.json +++ b/package.json @@ -132,6 +132,6 @@ "optionalDependencies": { "windows-foreground-love": "0.1.0", "windows-mutex": "^0.2.0", - "windows-process-tree": "0.1.6" + "windows-process-tree": "0.2.0" } } diff --git a/src/typings/windows-process-tree.d.ts b/src/typings/windows-process-tree.d.ts index aec2670a5cd..b9db4ea76a8 100644 --- a/src/typings/windows-process-tree.d.ts +++ b/src/typings/windows-process-tree.d.ts @@ -4,13 +4,60 @@ *--------------------------------------------------------------------------------------------*/ declare module 'windows-process-tree' { - interface ProcessTreeNode { - pid: number, - name: string, - children: ProcessTreeNode[] + export enum ProcessDataFlag { + None = 0, + Memory = 1, + CommandLine = 2 } - function get(rootPid: number, callback: (tree: ProcessTreeNode) => void): void; + export interface IProcessInfo { + pid: number; + ppid: number; + name: string; - export = get; + /** + * The working set size of the process, in bytes. + */ + memory?: number; + + /** + * The string returned is at most 512 chars, strings exceeding this length are truncated. + */ + commandLine?: string; + } + + export interface IProcessCpuInfo extends IProcessInfo { + cpu?: number; + } + + export interface IProcessTreeNode { + pid: number; + name: string; + memory?: number; + commandLine?: string; + children: IProcessTreeNode[]; + } + + /** + * Returns a tree of processes with the rootPid process as the root. + * @param rootPid - The pid of the process that will be the root of the tree. + * @param callback - The callback to use with the returned list of processes. + * @param flags - The flags for what process data should be included. + */ + export function getProcessTree(rootPid: number, callback: (tree: IProcessTreeNode) => void, flags?: ProcessDataFlag): void; + + /** + * Returns a list of processes containing the rootPid process and all of its descendants. + * @param rootPid - The pid of the process of interest. + * @param callback - The callback to use with the returned set of processes. + * @param flags - The flags for what process data should be included. + */ + export function getProcessList(rootPid: number, callback: (processList: IProcessInfo[]) => void, flags?: ProcessDataFlag): void; + + /** + * Returns the list of processes annotated with cpu usage information. + * @param processList - The list of processes. + * @param callback - The callback to use with the returned list of processes. + */ + export function getProcessCpuUsage(processList: IProcessInfo[], callback: (processListWithCpu: IProcessCpuInfo[]) => void): void; } diff --git a/src/vs/workbench/parts/terminal/electron-browser/windowsShellHelper.ts b/src/vs/workbench/parts/terminal/electron-browser/windowsShellHelper.ts index 803ad86dd9c..ebd8347f02f 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/windowsShellHelper.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/windowsShellHelper.ts @@ -115,7 +115,7 @@ export class WindowsShellHelper { return this._currentRequest; } this._currentRequest = new TPromise(resolve => { - windowsProcessTree(this._rootProcessId, (tree) => { + windowsProcessTree.getProcessTree(this._rootProcessId, (tree) => { const name = this.traverseTree(tree); this._currentRequest = null; resolve(name); diff --git a/yarn.lock b/yarn.lock index 29d519dd7b8..611eae8b5b9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5969,9 +5969,9 @@ windows-mutex@^0.2.0: bindings "^1.2.1" nan "^2.1.0" -windows-process-tree@0.1.6: - version "0.1.6" - resolved "https://registry.yarnpkg.com/windows-process-tree/-/windows-process-tree-0.1.6.tgz#c2d942a944152ea749a4c1c0bdb769b2f570639f" +windows-process-tree@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/windows-process-tree/-/windows-process-tree-0.2.0.tgz#04dc0507df292a7984daf0d35861bd1ebaff7ae8" dependencies: nan "^2.6.2"