Commit 0b49d7a
authored
fix: prevent orphaned processes via stdin/ppid/onclose lifecycle guards (#77)
* fix: prevent orphaned processes via stdin/ppid/onclose lifecycle guards
Adds 4 missing lifecycle guards to main() that caused orphaned node
processes to accumulate (~27GB RAM from 41 orphans on a 32GB machine):
- stdin end/close listeners: detect client exit via pipe closure
- server.onclose: handle graceful MCP protocol disconnect
- PPID polling (5s, unref'd): cross-platform parent death detection
- SIGHUP handler: terminal close on Unix + Windows console close
* fix: address review — filter ESRCH, hoist cleanup registration
- PPID poll: only exit on ESRCH (process gone), ignore EPERM (process
alive but different UID — setuid, Linux security modules, etc.)
- Hoist stopAllWatchers + exit/signal listeners to before stdin/onclose
handlers, closing the race window where process.exit() could fire
during initProject() before the cleanup listener was registered1 parent a814b24 commit 0b49d7a
1 file changed
+48
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1612 | 1612 | | |
1613 | 1613 | | |
1614 | 1614 | | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
1615 | 1632 | | |
1616 | 1633 | | |
1617 | 1634 | | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
1618 | 1666 | | |
1619 | 1667 | | |
1620 | 1668 | | |
| |||
1634 | 1682 | | |
1635 | 1683 | | |
1636 | 1684 | | |
1637 | | - | |
1638 | | - | |
1639 | | - | |
1640 | | - | |
1641 | | - | |
1642 | | - | |
1643 | | - | |
1644 | | - | |
1645 | | - | |
1646 | | - | |
1647 | | - | |
1648 | | - | |
1649 | | - | |
1650 | | - | |
1651 | | - | |
1652 | | - | |
1653 | | - | |
1654 | 1685 | | |
1655 | 1686 | | |
1656 | 1687 | | |
| |||
0 commit comments