Commit f5ad522
committed
fix: centralize process lifecycle and cancellation handling
Add ProcessManager singleton for centralized process lifecycle management:
- Single AbortController per run for coordinated cancellation
- Process registry to track all spawned child processes
- Signal propagation (SIGINT/SIGTERM) to all children with process tree killing
- Terminal state restoration (cursor visibility) on cleanup
- Configurable timeouts via environment variables:
- MDFLOW_FETCH_TIMEOUT (default: 10s)
- MDFLOW_COMMAND_TIMEOUT (default: 30s)
- MDFLOW_AGENT_TIMEOUT (default: no timeout)
Integration points:
- spinner.ts: Coordinates cursor hide/show with ProcessManager
- command.ts: Registers spawned processes for cleanup
- imports.ts: Uses configurable command timeout, registers inline processes
- cli-runner.ts: Initializes ProcessManager, registers cleanup callbacks
- index.ts: Early initialization for EPIPE handling with cursor restoration1 parent 1ff8006 commit f5ad522
File tree
7 files changed
+794
-17
lines changed- src
7 files changed
+794
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
272 | 273 | | |
273 | 274 | | |
274 | 275 | | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
283 | 284 | | |
284 | 285 | | |
285 | 286 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
| |||
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
| 33 | + | |
28 | 34 | | |
29 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
30 | 45 | | |
31 | 46 | | |
32 | 47 | | |
| |||
330 | 345 | | |
331 | 346 | | |
332 | 347 | | |
333 | | - | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
334 | 353 | | |
335 | 354 | | |
336 | 355 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
264 | | - | |
265 | | - | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
266 | 279 | | |
267 | 280 | | |
268 | 281 | | |
| |||
957 | 970 | | |
958 | 971 | | |
959 | 972 | | |
| 973 | + | |
960 | 974 | | |
961 | 975 | | |
962 | 976 | | |
| |||
966 | 980 | | |
967 | 981 | | |
968 | 982 | | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
969 | 986 | | |
970 | 987 | | |
971 | 988 | | |
| |||
993 | 1010 | | |
994 | 1011 | | |
995 | 1012 | | |
| 1013 | + | |
| 1014 | + | |
996 | 1015 | | |
997 | 1016 | | |
998 | 1017 | | |
999 | 1018 | | |
1000 | | - | |
1001 | | - | |
| 1019 | + | |
| 1020 | + | |
1002 | 1021 | | |
1003 | 1022 | | |
1004 | 1023 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
17 | 24 | | |
18 | 25 | | |
19 | 26 | | |
20 | 27 | | |
| 28 | + | |
21 | 29 | | |
22 | 30 | | |
23 | 31 | | |
24 | 32 | | |
25 | 33 | | |
26 | 34 | | |
27 | 35 | | |
| 36 | + | |
28 | 37 | | |
29 | 38 | | |
30 | 39 | | |
| |||
0 commit comments