UNPKG

@theia/core

Version:

Theia is a cloud & desktop IDE framework implemented in TypeScript.

77 lines • 3.66 kB
import * as cp from 'child_process'; import { ILogger } from '../common/logger.js'; /** * `@theia/core` service with some process-related utilities. */ export declare class ProcessUtils { protected readonly logger: ILogger; /** * Kills the given process together with all of its descendants. * * This blocks the event loop, so that it can run in an `exit` handler, where the loop is no longer * available. Prefer {@link terminateChildProcessTrees} while the event loop is running, as listing * the descendants of a process can be slow, in particular on Windows. */ terminateProcessTree(ppid: number): void; /** * Kills all of the descendants of the given process, but not the process itself, without blocking * the event loop. * * @throws if the descendants of the process cannot be listed */ terminateChildProcessTrees(ppid: number): Promise<void>; protected winTerminateProcessTree(ppid: number): void; protected winTerminateChildProcessTrees(ppid: number): Promise<void>; /** * Forcefully kills the given processes together with all of their descendants. */ protected winTaskkillTrees(pids: number[]): void; /** * @returns the PIDs of the direct children of the given process, see {@link winGetChildPidsArgs} */ protected winGetChildPids(ppid: number): number[]; /** * @returns the PIDs of the direct children of the given process, see {@link winGetChildPidsArgs} */ protected winGetChildPidsAsync(ppid: number): Promise<number[]>; /** * @returns the arguments of a PowerShell command that prints the PIDs of the direct children of the * given process, one per line, except for: * - the PowerShell process that lists them, which is a child of the current process and exits right after * - the console host (`conhost.exe`) that Windows attaches to a process launched without a console, * which `taskkill` may fail to kill * - processes created before the given process: Windows does not update the parent of a process * when the parent exits and reuses PIDs, so these are the orphans of a previous process with the same PID */ protected winGetChildPidsArgs(ppid: number): string[]; /** * @param output the output of the command of {@link winGetChildPidsArgs} */ protected winParsePids(output: string): number[]; /** * @returns the absolute path of Windows PowerShell, so that it does not depend on the `PATH`, * or just its name if the Windows directory is unknown. */ protected winGetPowerShellPath(): string; protected unixTerminateProcessTree(ppid: number): void; protected unixTerminateChildProcessTrees(ppid: number): Promise<void>; protected unixKill(pid: number): void; protected unixGetPGID(pid: number): number; protected unixGetChildrenRecursive(ppid: number): Set<number>; /** * @param psOutput the output of `ps ax -o ppid=,pid=` * @returns the PIDs of all of the descendants of the given process */ protected unixParseChildrenRecursive(psOutput: string, ppid: number): Set<number>; /** * Runs the given executable without blocking the event loop. * * @throws if the executable cannot be run or exits with a non-zero code, or on timeout */ protected execFile(file: string, argv: string[], options?: cp.ExecFileOptions): Promise<{ stdout: string; stderr: string; }>; protected spawnSync(file: string, argv: string[], options?: cp.SpawnSyncOptions): cp.SpawnSyncReturns<string>; } //# sourceMappingURL=process-utils.d.ts.map