node-tree-kill icon indicating copy to clipboard operation
node-tree-kill copied to clipboard

Build process tree for macOS

Open jinmatt opened this issue 10 months ago • 2 comments

Fix for issue: https://github.com/pkrumins/node-tree-kill/issues/43

Issue: When using tree-kill on macOS within applications that frequently restart (such as NestJS in watch mode), the module fails with a spawn EBADF error. The error occurs in the buildProcessTree function when attempting to spawn child processes to get the process tree. This appears to be due to file descriptor handling issues specific to macOS.

The issue appears to be related to how spawn handles file descriptors on macOS when used recursively in rapid succession. The current implementation uses spawn to build the process tree, which can lead to file descriptor exhaustion or race conditions when processes are frequently being killed and restarted.

Fix Uses execSync with proper timeout and error handling specifically for macOS to avoid the EBADF issues. Adds a new function buildProcessTreeMacOS for macOS or darwin platform

jinmatt avatar Mar 12 '25 03:03 jinmatt