MCPcopy Create free account
hub / github.com/ChromeDevTools/chrome-devtools-mcp / getProcessCommandLine

Function getProcessCommandLine

src/daemon/utils.ts:102–132  ·  view source on GitHub ↗
(pid: number)

Source from the content-addressed store, hash-verified

100const verifiedDaemonPids = new Map<number, boolean>();
101
102function getProcessCommandLine(pid: number): string {
103 if (process.platform === 'linux' && fs.existsSync('/proc')) {
104 return fs
105 .readFileSync(`/proc/${pid}/cmdline`, 'utf-8')
106 .replaceAll('\0', ' ');
107 }
108 if (IS_WINDOWS) {
109 return childProcess.execFileSync(
110 'powershell.exe',
111 [
112 '-NoProfile',
113 '-NonInteractive',
114 '-Command',
115 `(Get-CimInstance Win32_Process -Filter "ProcessId = ${pid}").CommandLine`,
116 ],
117 {
118 encoding: 'utf-8',
119 stdio: ['ignore', 'pipe', 'ignore'],
120 windowsHide: true,
121 },
122 );
123 }
124 return childProcess.execFileSync(
125 'ps',
126 ['-p', String(pid), '-o', 'command='],
127 {
128 encoding: 'utf-8',
129 stdio: ['ignore', 'pipe', 'ignore'],
130 },
131 );
132}
133
134function isDaemonProcess(pid: number): boolean {
135 const cached = verifiedDaemonPids.get(pid);

Callers 1

isDaemonProcessFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected