Skip to content

Commit 44fe332

Browse files
committed
add dependency to track pid usage
1 parent d48f1b3 commit 44fe332

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

package-lock.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
},
7373
"dependencies": {
7474
"@types/node": "^22.7.5",
75+
"@types/pidusage": "^2.0.5",
76+
"pidusage": "^3.0.2",
7577
"vscode-nls": "^5.2.0",
7678
"vscode-nls-dev": "^4.0.4"
7779
}

packages/core/src/shared/utilities/processUtils.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as logger from '../logger'
99
import { Timeout, CancellationError, waitUntil } from './timeoutUtils'
1010
import { PollingSet } from './pollingSet'
1111
import { getLogger } from '../logger/logger'
12+
import pidusage from 'pidusage'
1213

1314
export interface RunParameterContext {
1415
/** Reports an error parsed from the stdin/stdout streams. */
@@ -82,15 +83,21 @@ class ChildProcessTracker extends Map<number, ChildProcess> {
8283
}
8384
}
8485

85-
public monitorProcesses() {
86+
public async monitorProcesses() {
8687
this.cleanUpProcesses()
8788
getLogger().debug(`Active running processes size: ${this.#processPoller.size}`)
8889

8990
for (const pid of this.#processPoller.values()) {
90-
const process = this.get(pid)
91-
if (process) {
92-
getLogger().debug(`Active running process: ${process.toString()}`)
93-
}
91+
await this.monitorProcess(pid)
92+
}
93+
}
94+
95+
private async monitorProcess(pid: number) {
96+
if (this.has(pid)) {
97+
const stats = await pidusage(pid)
98+
getLogger().debug(`stats for ${pid}: %O`, stats)
99+
} else {
100+
getLogger().warn(`Missing process with id ${pid}`)
94101
}
95102
}
96103

0 commit comments

Comments
 (0)