Repository navigation
Commit c3e1f38
committed
fix(manager): serialize module spawns so pipes don't leak
On macOS, std creates a child's stdio pipes with pipe() and only then
sets close-on-exec (Linux uses pipe2(O_CLOEXEC)). Modules are spawned
from their own threads, so at startup one module could inherit another
module's pipe ends. When the owning module exited, the pipe stayed open,
its reader never saw EOF, and Stopped wasn't sent until the other module
exited too, leaving a stale PID in the manager and no crash restart.
This predates the stderr capture, but piping stderr doubled the pipes
per module. Take a lock around spawn() so pipe creation and exec can't
interleave across module threads. The new stress test lost a Stopped
message in 2 of 3 runs without the lock and passes consistently with it.1 parent 1da317b commit c3e1f38
1 file changed
Lines changed: 61 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
760 | 760 | | |
761 | 761 | | |
762 | 762 | | |
763 | | - | |
764 | | - | |
765 | | - | |
766 | | - | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
767 | 770 | | |
768 | 771 | | |
769 | 772 | | |
| |||
880 | 883 | | |
881 | 884 | | |
882 | 885 | | |
883 | | - | |
884 | | - | |
885 | | - | |
886 | | - | |
887 | | - | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
888 | 894 | | |
889 | 895 | | |
890 | 896 | | |
| |||
1017 | 1023 | | |
1018 | 1024 | | |
1019 | 1025 | | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
1020 | 1032 | | |
1021 | 1033 | | |
1022 | 1034 | | |
| |||
1377 | 1389 | | |
1378 | 1390 | | |
1379 | 1391 | | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
1380 | 1432 | | |
1381 | 1433 | | |
1382 | 1434 | | |
| |||
0 commit comments