@theia/core 1.78.0-next.4 → 1.78.0-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/catalog.json +37 -10
- package/lib/node/process-utils.d.ts +125 -2
- package/lib/node/process-utils.d.ts.map +1 -1
- package/lib/node/process-utils.js +297 -25
- package/lib/node/process-utils.js.map +1 -1
- package/lib/node/process-utils.slow-spec.js +78 -3
- package/lib/node/process-utils.slow-spec.js.map +1 -1
- package/lib/node/process-utils.spec.js +237 -2
- package/lib/node/process-utils.spec.js.map +1 -1
- package/lib/node/test/exiting-backend.d.ts +5 -0
- package/lib/node/test/exiting-backend.d.ts.map +1 -1
- package/lib/node/test/exiting-backend.js +16 -3
- package/lib/node/test/exiting-backend.js.map +1 -1
- package/package.json +4 -4
- package/src/node/process-utils.slow-spec.ts +90 -3
- package/src/node/process-utils.spec.ts +268 -3
- package/src/node/process-utils.ts +342 -24
- package/src/node/test/exiting-backend.ts +17 -3
package/lib/browser/catalog.json
CHANGED
|
@@ -563,6 +563,12 @@
|
|
|
563
563
|
"fileMatch": [".appsemblerc.yaml"],
|
|
564
564
|
"url": "https://gitlab.com/appsemble/appsemble/-/raw/HEAD/packages/cli/assets/appsemblerc.schema.json"
|
|
565
565
|
},
|
|
566
|
+
{
|
|
567
|
+
"name": "appfiles.json",
|
|
568
|
+
"description": "Declares the files an app leaves outside its package and what each one is, for backup, migration, cleanup and uninstall tools",
|
|
569
|
+
"fileMatch": ["appfiles.json"],
|
|
570
|
+
"url": "https://raw.githubusercontent.com/tw93/appfiles/main/appfiles.schema.json"
|
|
571
|
+
},
|
|
566
572
|
{
|
|
567
573
|
"name": "appsscript.json",
|
|
568
574
|
"description": "Google Apps Script manifest file",
|
|
@@ -757,7 +763,11 @@
|
|
|
757
763
|
{
|
|
758
764
|
"name": "Aurora Agile Meta-Framework",
|
|
759
765
|
"description": "Yaml for Aurora Agile Meta-Framework",
|
|
760
|
-
"fileMatch": [
|
|
766
|
+
"fileMatch": [
|
|
767
|
+
"*.aurora.yaml",
|
|
768
|
+
"*.aurora.yml",
|
|
769
|
+
"**/cliter/*/*.module.yaml"
|
|
770
|
+
],
|
|
761
771
|
"url": "https://www.schemastore.org/aurora-2.0.json",
|
|
762
772
|
"versions": {
|
|
763
773
|
"1.0": "https://www.schemastore.org/aurora-1.0.json",
|
|
@@ -1594,6 +1604,12 @@
|
|
|
1594
1604
|
"fileMatch": [],
|
|
1595
1605
|
"url": "https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/partial-scheduled.json"
|
|
1596
1606
|
},
|
|
1607
|
+
{
|
|
1608
|
+
"name": "partial-workers.json",
|
|
1609
|
+
"description": "Background workers configuration for pyproject.toml",
|
|
1610
|
+
"fileMatch": [],
|
|
1611
|
+
"url": "https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/partial-workers.json"
|
|
1612
|
+
},
|
|
1597
1613
|
{
|
|
1598
1614
|
"name": "partial-inwards.json",
|
|
1599
1615
|
"description": "Inwards architecture linter configuration for pyproject.toml",
|
|
@@ -1760,12 +1776,6 @@
|
|
|
1760
1776
|
],
|
|
1761
1777
|
"url": "https://raw.githubusercontent.com/eliashaeussler/cache-warmup/main/res/cache-warmup-config.schema.json"
|
|
1762
1778
|
},
|
|
1763
|
-
{
|
|
1764
|
-
"name": "Calibration Reporting Standard (CRS) v0.1",
|
|
1765
|
-
"description": "13-field structured attestation protocol for AI agent calibration disclosure in regulated financial systems. Implements ISO 42001 Clause 9.1 for agentic AI",
|
|
1766
|
-
"fileMatch": ["crs-attestation.json", "*.crs-attestation.json"],
|
|
1767
|
-
"url": "https://ericchantc.github.io/crs-specification/crs-v0.1-schema.json"
|
|
1768
|
-
},
|
|
1769
1779
|
{
|
|
1770
1780
|
"name": "Calqulus pipeline",
|
|
1771
1781
|
"description": "Qualisys Calqulus pipeline",
|
|
@@ -5070,10 +5080,11 @@
|
|
|
5070
5080
|
},
|
|
5071
5081
|
{
|
|
5072
5082
|
"name": "Jsontron",
|
|
5073
|
-
"description": "Jsontron vocabulary: rules and
|
|
5074
|
-
"url": "https://www.schemastore.org/jsontron-0.
|
|
5083
|
+
"description": "Jsontron vocabulary: Schematron-like rules, assert, report, and let keywords with id/flag/role metadata, over JSON Schema, using jq expressions",
|
|
5084
|
+
"url": "https://www.schemastore.org/jsontron-0.2.json",
|
|
5075
5085
|
"versions": {
|
|
5076
|
-
"0.1": "https://www.schemastore.org/jsontron-0.1.json"
|
|
5086
|
+
"0.1": "https://www.schemastore.org/jsontron-0.1.json",
|
|
5087
|
+
"0.2": "https://www.schemastore.org/jsontron-0.2.json"
|
|
5077
5088
|
}
|
|
5078
5089
|
},
|
|
5079
5090
|
{
|
|
@@ -5616,6 +5627,16 @@
|
|
|
5616
5627
|
"fileMatch": ["mimetypes.json"],
|
|
5617
5628
|
"url": "https://www.schemastore.org/mimetypes.json"
|
|
5618
5629
|
},
|
|
5630
|
+
{
|
|
5631
|
+
"name": "MikroTik MCP",
|
|
5632
|
+
"description": "MikroTik MCP server configuration",
|
|
5633
|
+
"fileMatch": [
|
|
5634
|
+
"mikrotik-mcp.json",
|
|
5635
|
+
"mikrotik-mcp.config.json",
|
|
5636
|
+
"**/.mikrotik-mcp/config.json"
|
|
5637
|
+
],
|
|
5638
|
+
"url": "https://www.schemastore.org/mikrotik-mcp.json"
|
|
5639
|
+
},
|
|
5619
5640
|
{
|
|
5620
5641
|
"name": "Minecraft Data Pack Advancement",
|
|
5621
5642
|
"description": "Configuration file defining an advancement for a data pack for Minecraft",
|
|
@@ -7811,6 +7832,12 @@
|
|
|
7811
7832
|
],
|
|
7812
7833
|
"url": "https://www.schemastore.org/snowflake-connections.json"
|
|
7813
7834
|
},
|
|
7835
|
+
{
|
|
7836
|
+
"name": "Solaria",
|
|
7837
|
+
"description": "Solaria agent, environment and MCP server definitions",
|
|
7838
|
+
"fileMatch": ["solaria.yaml", "solaria.yml"],
|
|
7839
|
+
"url": "https://solaria.sh/schemas/v1alpha1/solaria.json"
|
|
7840
|
+
},
|
|
7814
7841
|
{
|
|
7815
7842
|
"name": "Solarxy project config",
|
|
7816
7843
|
"description": "Solarxy 3D model viewer and validator project configuration",
|
|
@@ -1,10 +1,54 @@
|
|
|
1
1
|
import * as cp from 'child_process';
|
|
2
2
|
import { ILogger } from '../common/logger.js';
|
|
3
|
+
/**
|
|
4
|
+
* A process as listed by `ps`.
|
|
5
|
+
*/
|
|
6
|
+
export interface UnixProcessInfo {
|
|
7
|
+
pid: number;
|
|
8
|
+
ppid: number;
|
|
9
|
+
pgid: number;
|
|
10
|
+
/**
|
|
11
|
+
* As printed by `ps`. Only meant to be compared with another listing, to tell a process apart from a later
|
|
12
|
+
* one with the same PID.
|
|
13
|
+
*/
|
|
14
|
+
startTime: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A process that was sent `SIGTERM` and is killed with `SIGKILL` if it is still running at its deadline.
|
|
18
|
+
*/
|
|
19
|
+
export interface UnixForceKillTarget {
|
|
20
|
+
startTime: string;
|
|
21
|
+
/**
|
|
22
|
+
* In milliseconds, on the monotonic clock of `performance.now()`.
|
|
23
|
+
*/
|
|
24
|
+
deadline: number;
|
|
25
|
+
}
|
|
3
26
|
/**
|
|
4
27
|
* `@theia/core` service with some process-related utilities.
|
|
5
28
|
*/
|
|
6
29
|
export declare class ProcessUtils {
|
|
7
30
|
protected readonly logger: ILogger;
|
|
31
|
+
/**
|
|
32
|
+
* How long the processes of a tree have to exit after `SIGTERM` before they are killed with `SIGKILL`,
|
|
33
|
+
* in milliseconds, see {@link unixTerminateProcessTree}.
|
|
34
|
+
*/
|
|
35
|
+
protected readonly unixForceKillDelay: number;
|
|
36
|
+
/**
|
|
37
|
+
* How long {@link terminateChildProcessTrees} waits for processes to exit after `SIGTERM` before it kills
|
|
38
|
+
* them with `SIGKILL`, in milliseconds, measured from the start of the call. It is shorter than
|
|
39
|
+
* {@link unixForceKillDelay}, as it delays the exit of the current process. Listing the processes before
|
|
40
|
+
* `SIGKILL` can take up to another second.
|
|
41
|
+
*/
|
|
42
|
+
protected readonly unixChildProcessTreesForceKillDelay: number;
|
|
43
|
+
/**
|
|
44
|
+
* The processes that were sent `SIGTERM` and are to be killed with `SIGKILL` if they are still running
|
|
45
|
+
* at their deadline, by PID.
|
|
46
|
+
*/
|
|
47
|
+
protected readonly unixForceKillTargets: Map<number, UnixForceKillTarget>;
|
|
48
|
+
/**
|
|
49
|
+
* The timer of {@link unixScheduleForceKill}.
|
|
50
|
+
*/
|
|
51
|
+
protected unixForceKillTimer: ReturnType<typeof setTimeout> | undefined;
|
|
8
52
|
/**
|
|
9
53
|
* Kills the given process together with all of its descendants.
|
|
10
54
|
*
|
|
@@ -15,7 +59,8 @@ export declare class ProcessUtils {
|
|
|
15
59
|
terminateProcessTree(ppid: number): void;
|
|
16
60
|
/**
|
|
17
61
|
* Kills all of the descendants of the given process, but not the process itself, without blocking
|
|
18
|
-
* the event loop.
|
|
62
|
+
* the event loop. On Unix, it resolves once the processes have exited, or have been killed with `SIGKILL`
|
|
63
|
+
* after {@link unixChildProcessTreesForceKillDelay}.
|
|
19
64
|
*
|
|
20
65
|
* @throws if the descendants of the process cannot be listed
|
|
21
66
|
*/
|
|
@@ -53,9 +98,87 @@ export declare class ProcessUtils {
|
|
|
53
98
|
* or just its name if the Windows directory is unknown.
|
|
54
99
|
*/
|
|
55
100
|
protected winGetPowerShellPath(): string;
|
|
101
|
+
/**
|
|
102
|
+
* Sends `SIGTERM` to the given process, its descendants and, if it leads a process group, the members of
|
|
103
|
+
* its group. Those that are still running {@link unixForceKillDelay} later are then killed with `SIGKILL`.
|
|
104
|
+
*
|
|
105
|
+
* The tree of the current process is only terminated when it exits, so its own processes only get `SIGTERM`.
|
|
106
|
+
* The processes of earlier trees that are still waiting for their deadline are killed with `SIGKILL` right
|
|
107
|
+
* away instead, as they would outlive the current process otherwise.
|
|
108
|
+
*/
|
|
56
109
|
protected unixTerminateProcessTree(ppid: number): void;
|
|
110
|
+
protected unixSendSigterm(ppid: number, descendants: Iterable<number>, isGroupLeader: boolean): void;
|
|
111
|
+
/**
|
|
112
|
+
* Sends `SIGTERM` to the descendants of the given process and, if it leads a process group, to the other
|
|
113
|
+
* members of its group, which may have been reparented. The ones that are still running
|
|
114
|
+
* {@link unixChildProcessTreesForceKillDelay} after the call started are killed with `SIGKILL`, together
|
|
115
|
+
* with the processes of earlier calls of {@link unixTerminateProcessTree} that are still running.
|
|
116
|
+
*/
|
|
57
117
|
protected unixTerminateChildProcessTrees(ppid: number): Promise<void>;
|
|
58
|
-
protected
|
|
118
|
+
protected unixSendSigtermToAll(pids: Iterable<number>): void;
|
|
119
|
+
/**
|
|
120
|
+
* Records the given processes as {@link unixForceKillTargets}, except for the current process. A process
|
|
121
|
+
* that is already recorded keeps its earlier deadline.
|
|
122
|
+
*/
|
|
123
|
+
protected unixAddForceKillTargets(processes: Map<number, UnixProcessInfo>, pids: Iterable<number>, deadline: number): void;
|
|
124
|
+
/**
|
|
125
|
+
* Schedules {@link unixForceKillDueTargets} for the earliest deadline of the {@link unixForceKillTargets},
|
|
126
|
+
* and again after that for the remaining ones. The timer does not keep the current process alive.
|
|
127
|
+
*/
|
|
128
|
+
protected unixScheduleForceKill(): void;
|
|
129
|
+
/**
|
|
130
|
+
* Waits until all of the {@link unixForceKillTargets} have exited, or until the given deadline.
|
|
131
|
+
*/
|
|
132
|
+
protected unixWaitForForceKillTargets(deadline: number): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Kills the {@link unixForceKillTargets} whose deadline has passed with `SIGKILL`, if they are still running
|
|
135
|
+
* and their PID has not been reused since. They stay in the map until the processes have been listed, so that
|
|
136
|
+
* a shutdown in the meantime still finds them. Never rejects.
|
|
137
|
+
*/
|
|
138
|
+
protected unixForceKillDueTargets(): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* Kills all of the {@link unixForceKillTargets} with `SIGKILL` without waiting for their deadline, if they are
|
|
141
|
+
* still running and their PID has not been reused since. This blocks the event loop.
|
|
142
|
+
*/
|
|
143
|
+
protected unixForceKillPendingTargets(): void;
|
|
144
|
+
/**
|
|
145
|
+
* @returns the given targets that are still running
|
|
146
|
+
*/
|
|
147
|
+
protected unixGetSurvivors(targets: Map<number, UnixForceKillTarget>): Map<number, UnixForceKillTarget>;
|
|
148
|
+
/**
|
|
149
|
+
* Kills the given targets with `SIGKILL` if they are listed in `processes` with the same start time.
|
|
150
|
+
*/
|
|
151
|
+
protected unixForceKillSurvivors(targets: Map<number, UnixForceKillTarget>, processes: Map<number, UnixProcessInfo>): void;
|
|
152
|
+
protected unixIsAlive(pid: number): boolean;
|
|
153
|
+
/**
|
|
154
|
+
* @returns the PIDs of all of the descendants of the given process
|
|
155
|
+
*/
|
|
156
|
+
protected unixGetDescendants(processes: Iterable<{
|
|
157
|
+
pid: number;
|
|
158
|
+
ppid: number;
|
|
159
|
+
}>, ppid: number): Set<number>;
|
|
160
|
+
/**
|
|
161
|
+
* @returns the PIDs of the members of the given process group, including those that were reparented
|
|
162
|
+
*/
|
|
163
|
+
protected unixGetGroupMembers(processes: Map<number, UnixProcessInfo>, pgid: number): number[];
|
|
164
|
+
/**
|
|
165
|
+
* @returns all processes, see {@link unixListProcesses}, or `undefined` if they cannot be listed
|
|
166
|
+
*/
|
|
167
|
+
protected unixTryListProcesses(): Map<number, UnixProcessInfo> | undefined;
|
|
168
|
+
/**
|
|
169
|
+
* @returns all processes by PID, from a single run of `ps`
|
|
170
|
+
*/
|
|
171
|
+
protected unixListProcesses(): Map<number, UnixProcessInfo>;
|
|
172
|
+
/**
|
|
173
|
+
* @returns all processes by PID, from a single run of `ps`, without blocking the event loop
|
|
174
|
+
*/
|
|
175
|
+
protected unixListProcessesAsync(): Promise<Map<number, UnixProcessInfo>>;
|
|
176
|
+
protected unixListProcessesOptions(): cp.SpawnSyncOptions & cp.ExecFileOptions;
|
|
177
|
+
/**
|
|
178
|
+
* @param psOutput the output of `ps` with {@link UNIX_LIST_PROCESSES_ARGS}
|
|
179
|
+
*/
|
|
180
|
+
protected unixParseProcesses(psOutput: string): Map<number, UnixProcessInfo>;
|
|
181
|
+
protected unixKill(pid: number, signal?: NodeJS.Signals): void;
|
|
59
182
|
protected unixGetPGID(pid: number): number;
|
|
60
183
|
protected unixGetChildrenRecursive(ppid: number): Set<number>;
|
|
61
184
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-utils.d.ts","sourceRoot":"","sources":["../../src/node/process-utils.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,MAAM,eAAe,CAAC;AAGpC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"process-utils.d.ts","sourceRoot":"","sources":["../../src/node/process-utils.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,MAAM,eAAe,CAAC;AAGpC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AA4B9C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,qBACa,YAAY;IAGrB,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAEnC;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAQ;IAErD;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,CAAC,mCAAmC,EAAE,MAAM,CAAQ;IAEtE;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,oBAAoB,mCAA0C;IAEjF;;OAEG;IACH,SAAS,CAAC,kBAAkB,EAAE,UA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true, timeout: WIN_LIST_CHILDREN_TIMEOUT_MS };
|
|
29
|
+
/**
|
|
30
|
+
* The arguments of `ps` that list all processes with their parent, process group and start time.
|
|
31
|
+
* `lstart` goes last, as it contains spaces.
|
|
32
|
+
*/
|
|
33
|
+
const UNIX_LIST_PROCESSES_ARGS = ['-A', '-o', 'pid=,ppid=,pgid=,lstart='];
|
|
34
|
+
/**
|
|
35
|
+
* How long to wait for `ps` to list all processes before giving up, in milliseconds.
|
|
36
|
+
*/
|
|
37
|
+
const UNIX_LIST_PROCESSES_TIMEOUT_MS = 1000;
|
|
38
|
+
/**
|
|
39
|
+
* How often to check whether processes that were sent `SIGTERM` have exited, in milliseconds.
|
|
40
|
+
*/
|
|
41
|
+
const UNIX_FORCE_KILL_POLL_INTERVAL_MS = 100;
|
|
29
42
|
/**
|
|
30
43
|
* `@theia/core` service with some process-related utilities.
|
|
31
44
|
*/
|
|
32
45
|
let ProcessUtils = class ProcessUtils {
|
|
46
|
+
constructor() {
|
|
47
|
+
/**
|
|
48
|
+
* How long the processes of a tree have to exit after `SIGTERM` before they are killed with `SIGKILL`,
|
|
49
|
+
* in milliseconds, see {@link unixTerminateProcessTree}.
|
|
50
|
+
*/
|
|
51
|
+
this.unixForceKillDelay = 5000;
|
|
52
|
+
/**
|
|
53
|
+
* How long {@link terminateChildProcessTrees} waits for processes to exit after `SIGTERM` before it kills
|
|
54
|
+
* them with `SIGKILL`, in milliseconds, measured from the start of the call. It is shorter than
|
|
55
|
+
* {@link unixForceKillDelay}, as it delays the exit of the current process. Listing the processes before
|
|
56
|
+
* `SIGKILL` can take up to another second.
|
|
57
|
+
*/
|
|
58
|
+
this.unixChildProcessTreesForceKillDelay = 2000;
|
|
59
|
+
/**
|
|
60
|
+
* The processes that were sent `SIGTERM` and are to be killed with `SIGKILL` if they are still running
|
|
61
|
+
* at their deadline, by PID.
|
|
62
|
+
*/
|
|
63
|
+
this.unixForceKillTargets = new Map();
|
|
64
|
+
}
|
|
33
65
|
/**
|
|
34
66
|
* Kills the given process together with all of its descendants.
|
|
35
67
|
*
|
|
@@ -47,7 +79,8 @@ let ProcessUtils = class ProcessUtils {
|
|
|
47
79
|
}
|
|
48
80
|
/**
|
|
49
81
|
* Kills all of the descendants of the given process, but not the process itself, without blocking
|
|
50
|
-
* the event loop.
|
|
82
|
+
* the event loop. On Unix, it resolves once the processes have exited, or have been killed with `SIGKILL`
|
|
83
|
+
* after {@link unixChildProcessTreesForceKillDelay}.
|
|
51
84
|
*
|
|
52
85
|
* @throws if the descendants of the process cannot be listed
|
|
53
86
|
*/
|
|
@@ -160,14 +193,33 @@ let ProcessUtils = class ProcessUtils {
|
|
|
160
193
|
// in this directory. PowerShell 7 and later are a separate, optional installation (`pwsh.exe`).
|
|
161
194
|
return path.win32.join(systemRoot, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe');
|
|
162
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Sends `SIGTERM` to the given process, its descendants and, if it leads a process group, the members of
|
|
198
|
+
* its group. Those that are still running {@link unixForceKillDelay} later are then killed with `SIGKILL`.
|
|
199
|
+
*
|
|
200
|
+
* The tree of the current process is only terminated when it exits, so its own processes only get `SIGTERM`.
|
|
201
|
+
* The processes of earlier trees that are still waiting for their deadline are killed with `SIGKILL` right
|
|
202
|
+
* away instead, as they would outlive the current process otherwise.
|
|
203
|
+
*/
|
|
163
204
|
unixTerminateProcessTree(ppid) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
205
|
+
if (ppid === process.pid) {
|
|
206
|
+
this.unixForceKillPendingTargets();
|
|
207
|
+
}
|
|
208
|
+
const processes = ppid === process.pid ? undefined : this.unixTryListProcesses();
|
|
209
|
+
if (!processes) {
|
|
210
|
+
this.unixSendSigterm(ppid, this.unixGetChildrenRecursive(ppid), ppid === this.unixGetPGID(ppid));
|
|
211
|
+
return;
|
|
169
212
|
}
|
|
170
|
-
|
|
213
|
+
const isGroupLeader = processes.get(ppid)?.pgid === ppid;
|
|
214
|
+
const descendants = this.unixGetDescendants(processes.values(), ppid);
|
|
215
|
+
this.unixSendSigterm(ppid, descendants, isGroupLeader);
|
|
216
|
+
const groupMembers = isGroupLeader ? this.unixGetGroupMembers(processes, ppid) : [];
|
|
217
|
+
this.unixAddForceKillTargets(processes, [ppid, ...descendants, ...groupMembers], performance.now() + this.unixForceKillDelay);
|
|
218
|
+
this.unixScheduleForceKill();
|
|
219
|
+
}
|
|
220
|
+
unixSendSigterm(ppid, descendants, isGroupLeader) {
|
|
221
|
+
this.unixSendSigtermToAll(descendants);
|
|
222
|
+
if (isGroupLeader) {
|
|
171
223
|
// When a process pgid === pid this means the the process is a group leader.
|
|
172
224
|
// We can then kill every process part of its group by doing `kill(-pgid)`.
|
|
173
225
|
// This can catch leaked processes under `init` that are still part of the group.
|
|
@@ -175,18 +227,251 @@ let ProcessUtils = class ProcessUtils {
|
|
|
175
227
|
}
|
|
176
228
|
this.unixKill(ppid);
|
|
177
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* Sends `SIGTERM` to the descendants of the given process and, if it leads a process group, to the other
|
|
232
|
+
* members of its group, which may have been reparented. The ones that are still running
|
|
233
|
+
* {@link unixChildProcessTreesForceKillDelay} after the call started are killed with `SIGKILL`, together
|
|
234
|
+
* with the processes of earlier calls of {@link unixTerminateProcessTree} that are still running.
|
|
235
|
+
*/
|
|
178
236
|
async unixTerminateChildProcessTrees(ppid) {
|
|
179
|
-
const
|
|
180
|
-
|
|
237
|
+
const deadline = performance.now() + this.unixChildProcessTreesForceKillDelay;
|
|
238
|
+
let processes;
|
|
239
|
+
try {
|
|
240
|
+
processes = await this.unixListProcessesAsync();
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
this.logger.warn('Failed to list the start times of processes, child processes will only be sent SIGTERM', error);
|
|
244
|
+
const { stdout } = await this.execFile('ps', ['ax', '-o', 'ppid=,pid='], { timeout: UNIX_LIST_PROCESSES_TIMEOUT_MS });
|
|
245
|
+
this.unixSendSigtermToAll(this.unixParseChildrenRecursive(stdout, ppid));
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const pids = this.unixGetDescendants(processes.values(), ppid);
|
|
249
|
+
if (processes.get(ppid)?.pgid === ppid) {
|
|
250
|
+
this.unixGetGroupMembers(processes, ppid).forEach(pid => pids.add(pid));
|
|
251
|
+
pids.delete(ppid);
|
|
252
|
+
}
|
|
253
|
+
this.unixSendSigtermToAll(pids);
|
|
254
|
+
this.unixAddForceKillTargets(processes, pids, deadline);
|
|
255
|
+
for (const target of this.unixForceKillTargets.values()) {
|
|
256
|
+
target.deadline = Math.min(target.deadline, deadline);
|
|
257
|
+
}
|
|
258
|
+
await this.unixWaitForForceKillTargets(deadline);
|
|
259
|
+
await this.unixForceKillDueTargets();
|
|
260
|
+
}
|
|
261
|
+
unixSendSigtermToAll(pids) {
|
|
262
|
+
for (const pid of pids) {
|
|
181
263
|
// Prevent killing the current process:
|
|
182
264
|
if (pid !== process.pid) {
|
|
183
265
|
this.unixKill(pid);
|
|
184
266
|
}
|
|
185
267
|
}
|
|
186
268
|
}
|
|
187
|
-
|
|
269
|
+
/**
|
|
270
|
+
* Records the given processes as {@link unixForceKillTargets}, except for the current process. A process
|
|
271
|
+
* that is already recorded keeps its earlier deadline.
|
|
272
|
+
*/
|
|
273
|
+
unixAddForceKillTargets(processes, pids, deadline) {
|
|
274
|
+
for (const pid of pids) {
|
|
275
|
+
const info = processes.get(pid);
|
|
276
|
+
if (pid === process.pid || !info) {
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
const existing = this.unixForceKillTargets.get(pid);
|
|
280
|
+
if (existing?.startTime === info.startTime && existing.deadline <= deadline) {
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
this.unixForceKillTargets.set(pid, { startTime: info.startTime, deadline });
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Schedules {@link unixForceKillDueTargets} for the earliest deadline of the {@link unixForceKillTargets},
|
|
288
|
+
* and again after that for the remaining ones. The timer does not keep the current process alive.
|
|
289
|
+
*/
|
|
290
|
+
unixScheduleForceKill() {
|
|
291
|
+
clearTimeout(this.unixForceKillTimer);
|
|
292
|
+
this.unixForceKillTimer = undefined;
|
|
293
|
+
if (this.unixForceKillTargets.size === 0) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
const deadline = Math.min(...Array.from(this.unixForceKillTargets.values(), target => target.deadline));
|
|
297
|
+
this.unixForceKillTimer = setTimeout(async () => {
|
|
298
|
+
this.unixForceKillTimer = undefined;
|
|
299
|
+
await this.unixForceKillDueTargets();
|
|
300
|
+
this.unixScheduleForceKill();
|
|
301
|
+
}, Math.max(0, deadline - performance.now())).unref();
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Waits until all of the {@link unixForceKillTargets} have exited, or until the given deadline.
|
|
305
|
+
*/
|
|
306
|
+
async unixWaitForForceKillTargets(deadline) {
|
|
307
|
+
for (;;) {
|
|
308
|
+
for (const pid of this.unixForceKillTargets.keys()) {
|
|
309
|
+
if (!this.unixIsAlive(pid)) {
|
|
310
|
+
this.unixForceKillTargets.delete(pid);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
const remaining = deadline - performance.now();
|
|
314
|
+
if (this.unixForceKillTargets.size === 0 || remaining <= 0) {
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
await new Promise(resolve => setTimeout(resolve, Math.min(remaining, UNIX_FORCE_KILL_POLL_INTERVAL_MS)));
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Kills the {@link unixForceKillTargets} whose deadline has passed with `SIGKILL`, if they are still running
|
|
322
|
+
* and their PID has not been reused since. They stay in the map until the processes have been listed, so that
|
|
323
|
+
* a shutdown in the meantime still finds them. Never rejects.
|
|
324
|
+
*/
|
|
325
|
+
async unixForceKillDueTargets() {
|
|
326
|
+
const now = performance.now();
|
|
327
|
+
const due = new Map();
|
|
328
|
+
for (const [pid, target] of this.unixForceKillTargets) {
|
|
329
|
+
if (target.deadline <= now) {
|
|
330
|
+
due.set(pid, target);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
const survivors = this.unixGetSurvivors(due);
|
|
334
|
+
for (const pid of due.keys()) {
|
|
335
|
+
if (!survivors.has(pid)) {
|
|
336
|
+
this.unixForceKillTargets.delete(pid);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if (survivors.size === 0) {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
let processes;
|
|
343
|
+
try {
|
|
344
|
+
processes = await this.unixListProcessesAsync();
|
|
345
|
+
}
|
|
346
|
+
catch (error) {
|
|
347
|
+
this.logger.error('Failed to kill the remaining processes of a process tree', error);
|
|
348
|
+
}
|
|
349
|
+
// Leave out the targets that were handled or replaced in the meantime, e.g. on exit.
|
|
350
|
+
const pending = new Map(Array.from(survivors).filter(([pid, target]) => this.unixForceKillTargets.get(pid) === target));
|
|
351
|
+
pending.forEach((_, pid) => this.unixForceKillTargets.delete(pid));
|
|
352
|
+
if (processes) {
|
|
353
|
+
this.unixForceKillSurvivors(pending, processes);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Kills all of the {@link unixForceKillTargets} with `SIGKILL` without waiting for their deadline, if they are
|
|
358
|
+
* still running and their PID has not been reused since. This blocks the event loop.
|
|
359
|
+
*/
|
|
360
|
+
unixForceKillPendingTargets() {
|
|
361
|
+
const targets = new Map(this.unixForceKillTargets);
|
|
362
|
+
this.unixForceKillTargets.clear();
|
|
363
|
+
clearTimeout(this.unixForceKillTimer);
|
|
364
|
+
this.unixForceKillTimer = undefined;
|
|
365
|
+
const survivors = this.unixGetSurvivors(targets);
|
|
366
|
+
if (survivors.size === 0) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
188
369
|
try {
|
|
189
|
-
|
|
370
|
+
this.unixForceKillSurvivors(survivors, this.unixListProcesses());
|
|
371
|
+
}
|
|
372
|
+
catch (error) {
|
|
373
|
+
this.logger.error('Failed to kill the remaining processes of a process tree', error);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* @returns the given targets that are still running
|
|
378
|
+
*/
|
|
379
|
+
unixGetSurvivors(targets) {
|
|
380
|
+
return new Map(Array.from(targets).filter(([pid]) => this.unixIsAlive(pid)));
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Kills the given targets with `SIGKILL` if they are listed in `processes` with the same start time.
|
|
384
|
+
*/
|
|
385
|
+
unixForceKillSurvivors(targets, processes) {
|
|
386
|
+
for (const [pid, target] of targets) {
|
|
387
|
+
if (processes.get(pid)?.startTime === target.startTime) {
|
|
388
|
+
this.logger.warn(`[${pid}] still running after SIGTERM, killing it with SIGKILL`);
|
|
389
|
+
this.unixKill(pid, 'SIGKILL');
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
unixIsAlive(pid) {
|
|
394
|
+
try {
|
|
395
|
+
process.kill(pid, 0);
|
|
396
|
+
return true;
|
|
397
|
+
}
|
|
398
|
+
catch (error) {
|
|
399
|
+
return error?.code !== 'ESRCH';
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* @returns the PIDs of all of the descendants of the given process
|
|
404
|
+
*/
|
|
405
|
+
unixGetDescendants(processes, ppid) {
|
|
406
|
+
const list = Array.from(processes);
|
|
407
|
+
const pids = new Set([ppid]);
|
|
408
|
+
// Keep looking for parent/child relationships while we keep finding new parents:
|
|
409
|
+
let size;
|
|
410
|
+
do {
|
|
411
|
+
size = pids.size;
|
|
412
|
+
for (const child of list) {
|
|
413
|
+
if (pids.has(child.ppid)) {
|
|
414
|
+
pids.add(child.pid);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
} while (size !== pids.size);
|
|
418
|
+
// Exclude the requested parent id:
|
|
419
|
+
pids.delete(ppid);
|
|
420
|
+
return pids;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* @returns the PIDs of the members of the given process group, including those that were reparented
|
|
424
|
+
*/
|
|
425
|
+
unixGetGroupMembers(processes, pgid) {
|
|
426
|
+
return Array.from(processes.values()).filter(info => info.pgid === pgid).map(info => info.pid);
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* @returns all processes, see {@link unixListProcesses}, or `undefined` if they cannot be listed
|
|
430
|
+
*/
|
|
431
|
+
unixTryListProcesses() {
|
|
432
|
+
try {
|
|
433
|
+
return this.unixListProcesses();
|
|
434
|
+
}
|
|
435
|
+
catch (error) {
|
|
436
|
+
this.logger.warn('Failed to list the start times of processes, a process tree will only be sent SIGTERM', error);
|
|
437
|
+
return undefined;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* @returns all processes by PID, from a single run of `ps`
|
|
442
|
+
*/
|
|
443
|
+
unixListProcesses() {
|
|
444
|
+
const { stdout } = this.spawnSync('ps', UNIX_LIST_PROCESSES_ARGS, this.unixListProcessesOptions());
|
|
445
|
+
return this.unixParseProcesses(stdout);
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* @returns all processes by PID, from a single run of `ps`, without blocking the event loop
|
|
449
|
+
*/
|
|
450
|
+
async unixListProcessesAsync() {
|
|
451
|
+
const { stdout } = await this.execFile('ps', UNIX_LIST_PROCESSES_ARGS, this.unixListProcessesOptions());
|
|
452
|
+
return this.unixParseProcesses(stdout);
|
|
453
|
+
}
|
|
454
|
+
unixListProcessesOptions() {
|
|
455
|
+
// A fixed locale and time zone keep the output of `lstart` comparable across runs.
|
|
456
|
+
return { env: { ...process.env, LC_ALL: 'C', TZ: 'UTC' }, timeout: UNIX_LIST_PROCESSES_TIMEOUT_MS };
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* @param psOutput the output of `ps` with {@link UNIX_LIST_PROCESSES_ARGS}
|
|
460
|
+
*/
|
|
461
|
+
unixParseProcesses(psOutput) {
|
|
462
|
+
const processes = new Map();
|
|
463
|
+
for (const line of psOutput.split('\n')) {
|
|
464
|
+
const match = line.trim().match(/^(\d+)\s+(\d+)\s+(\d+)\s+(.+)$/);
|
|
465
|
+
if (match) {
|
|
466
|
+
const pid = Number.parseInt(match[1], 10);
|
|
467
|
+
processes.set(pid, { pid, ppid: Number.parseInt(match[2], 10), pgid: Number.parseInt(match[3], 10), startTime: match[4] });
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return processes;
|
|
471
|
+
}
|
|
472
|
+
unixKill(pid, signal) {
|
|
473
|
+
try {
|
|
474
|
+
process.kill(pid, signal);
|
|
190
475
|
}
|
|
191
476
|
catch (error) {
|
|
192
477
|
// ESRCH means the process is already gone, which is the goal here. Log
|
|
@@ -209,7 +494,6 @@ let ProcessUtils = class ProcessUtils {
|
|
|
209
494
|
* @returns the PIDs of all of the descendants of the given process
|
|
210
495
|
*/
|
|
211
496
|
unixParseChildrenRecursive(psOutput, ppid) {
|
|
212
|
-
const pids = new Set([ppid]);
|
|
213
497
|
const matcher = /(\d+)\s+(\d+)/;
|
|
214
498
|
const psList = psOutput
|
|
215
499
|
.trim()
|
|
@@ -221,19 +505,7 @@ let ProcessUtils = class ProcessUtils {
|
|
|
221
505
|
pid: Number.parseInt(match[2], 10),
|
|
222
506
|
};
|
|
223
507
|
});
|
|
224
|
-
|
|
225
|
-
let size;
|
|
226
|
-
do {
|
|
227
|
-
size = pids.size;
|
|
228
|
-
for (const child of psList) {
|
|
229
|
-
if (pids.has(child.ppid)) {
|
|
230
|
-
pids.add(child.pid);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
} while (size !== pids.size);
|
|
234
|
-
// Exclude the requested parent id:
|
|
235
|
-
pids.delete(ppid);
|
|
236
|
-
return pids;
|
|
508
|
+
return this.unixGetDescendants(psList, ppid);
|
|
237
509
|
}
|
|
238
510
|
/**
|
|
239
511
|
* Runs the given executable without blocking the event loop.
|