|
| 1 | +/*--------------------------------------------------------------------------------------------- |
| 2 | + * Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | + * Licensed under the MIT License. See License.txt in the project root for license information. |
| 4 | + *--------------------------------------------------------------------------------------------*/ |
| 5 | + |
| 6 | +// Copied from the `@vscode/windows-process-tree` package. |
| 7 | +// The dependency is an optional dependency that is only used on Windows, |
| 8 | +// but we need the typings to compile on all platforms. |
| 9 | +// The `@types/windows-process-tree` package has also been deprecated. |
| 10 | +declare module '@vscode/windows-process-tree' { |
| 11 | + export enum ProcessDataFlag { |
| 12 | + None = 0, |
| 13 | + Memory = 1, |
| 14 | + CommandLine = 2 |
| 15 | + } |
| 16 | + |
| 17 | + export interface IProcessInfo { |
| 18 | + pid: number; |
| 19 | + ppid: number; |
| 20 | + name: string; |
| 21 | + |
| 22 | + /** |
| 23 | + * The working set size of the process, in bytes. |
| 24 | + */ |
| 25 | + memory?: number; |
| 26 | + |
| 27 | + /** |
| 28 | + * The string returned is at most 512 chars, strings exceeding this length are truncated. |
| 29 | + */ |
| 30 | + commandLine?: string; |
| 31 | + } |
| 32 | + |
| 33 | + export interface IProcessCpuInfo extends IProcessInfo { |
| 34 | + cpu?: number; |
| 35 | + } |
| 36 | + |
| 37 | + export interface IProcessTreeNode { |
| 38 | + pid: number; |
| 39 | + name: string; |
| 40 | + memory?: number; |
| 41 | + commandLine?: string; |
| 42 | + children: IProcessTreeNode[]; |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * Returns a tree of processes with the rootPid process as the root. |
| 47 | + * @param rootPid - The pid of the process that will be the root of the tree. |
| 48 | + * @param callback - The callback to use with the returned list of processes. |
| 49 | + * @param flags - The flags for what process data should be included. |
| 50 | + */ |
| 51 | + export function getProcessTree(rootPid: number, callback: (tree: IProcessTreeNode | undefined) => void, flags?: ProcessDataFlag): void; |
| 52 | + |
| 53 | + namespace getProcessTree { |
| 54 | + function __promisify__(rootPid: number, flags?: ProcessDataFlag): Promise<IProcessTreeNode>; |
| 55 | + } |
| 56 | + |
| 57 | + /** |
| 58 | + * Returns a list of processes containing the rootPid process and all of its descendants. |
| 59 | + * @param rootPid - The pid of the process of interest. |
| 60 | + * @param callback - The callback to use with the returned set of processes. |
| 61 | + * @param flags - The flags for what process data should be included. |
| 62 | + */ |
| 63 | + export function getProcessList(rootPid: number, callback: (processList: IProcessInfo[] | undefined) => void, flags?: ProcessDataFlag): void; |
| 64 | + |
| 65 | + namespace getProcessList { |
| 66 | + function __promisify__(rootPid: number, flags?: ProcessDataFlag): Promise<IProcessInfo[]>; |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * Returns the list of processes annotated with cpu usage information. |
| 71 | + * @param processList - The list of processes. |
| 72 | + * @param callback - The callback to use with the returned list of processes. |
| 73 | + */ |
| 74 | + export function getProcessCpuUsage(processList: IProcessInfo[], callback: (processListWithCpu: IProcessCpuInfo[]) => void): void; |
| 75 | + |
| 76 | + namespace getProcessCpuUsage { |
| 77 | + function __promisify__(processList: IProcessInfo[]): Promise<IProcessCpuInfo[]>; |
| 78 | + } |
| 79 | +} |
0 commit comments