Skip to content

Fix kill on drop on Windows #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

ozaner
Copy link

@ozaner ozaner commented May 6, 2025

📌 Summary

When a StdioTransport is dropped, it's child process is meant to be killed along with it. However this does not work on Windows, allowing for zombie stdio processes to stay alive in the background.

✨ Changes Made

Seems the code had separate sections for spawning in the child process on both Windows and Unix.

Fix was simple, instead of spawning a "cmd.exe" process and running the command on that:

let command = "cmd.exe".to_string();
let mut command_args = vec!["/c".to_string(), self.command.clone().unwrap_or_default()];
command_args.extend(self.args.clone().unwrap_or_default());

Just run the command directly (as in the Unix case):

let command = self.command.clone().unwrap_or_default();
let command_args = self.args.clone().unwrap_or_default();

In practice, this just meant removing the Windows specific code, and using the Unix specific code for both.

🛠️ Testing Steps

Try running a stdio mcp server that does not terminate upon the server closing (e.g. if it's a Typescript server add a setInterval). The Rust program will hang because of the zombie process.

💡 Additional Notes

I imagine this bug is a result of development/testing happening on Unix rather than Windows. I am currently developing on Windows so I was able to catch it. Other than this bug, everything else seems to work perfectly. 👍

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.

1 participant