(pid: string | number)
| 92 | * @deprecated Use getAncestorCommandsAsync instead |
| 93 | */ |
| 94 | export function getProcessCommand(pid: string | number): string | null { |
| 95 | try { |
| 96 | const pidStr = String(pid) |
| 97 | const command = |
| 98 | process.platform === 'win32' |
| 99 | ? `powershell.exe -NoProfile -Command "(Get-CimInstance Win32_Process -Filter \\"ProcessId=${pidStr}\\").CommandLine"` |
| 100 | : `ps -o command= -p ${pidStr}` |
| 101 | |
| 102 | const result = execSyncWithDefaults_DEPRECATED(command, { timeout: 1000 }) |
| 103 | return result ? result.trim() : null |
| 104 | } catch { |
| 105 | return null |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Gets the command lines for a process and its ancestors in a single call |
no test coverage detected