Skip to content

Conversation

@jinmatt
Copy link

@jinmatt jinmatt commented Mar 12, 2025

Fix for issue: #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

@MarkusWendorf
Copy link

Works for me, thank you Jinsu. Hope to get this merged eventually, currently using patch-package.

@Pierre-kfoury
Copy link

Works great for me too ! do we have news about the merge ? 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants