MCPcopy Index your code
hub / github.com/microsoft/vscode-js-debug / WindowsProcessTree

Class WindowsProcessTree

src/ui/processTree/windowsProcessTree.ts:8–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6import { IProcess, IProcessTree } from './processTree';
7
8export class WindowsProcessTree implements IProcessTree {
9 /**
10 * @inheritdoc
11 */
12 public async getWorkingDirectory() {
13 return undefined; // not supported
14 }
15
16 /**
17 * @inheritdoc
18 */
19 async lookup<T>(onEntry: (process: IProcess, accumulator: T) => T, initial: T): Promise<T> {
20 const win = await getWinUtils();
21 for (const proc of win.getProcessInfo()) {
22 let args = '';
23 let command: string;
24
25 const quoteEnd = proc.commandLine.indexOf('" ');
26 if (quoteEnd === -1) {
27 const space = proc.commandLine.indexOf(' ');
28 if (space === -1) {
29 command = proc.commandLine;
30 } else {
31 command = proc.commandLine.slice(0, space);
32 args = proc.commandLine.slice(space + 1);
33 }
34 } else {
35 command = proc.commandLine.slice(1, quoteEnd);
36 args = proc.commandLine.slice(quoteEnd + 2);
37 }
38
39 initial = onEntry({
40 args,
41 command,
42 date: proc.creationDate * 1000,
43 pid: proc.processId,
44 ppid: proc.parentProcessId,
45 }, initial);
46 }
47
48 return initial;
49 }
50}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected