Skip to content

Fixed kill command to work properly on linux and devcontainers#86

Open
pbendersky wants to merge 1 commit into
BrowserMCP:mainfrom
pbendersky:linux-kill-fix
Open

Fixed kill command to work properly on linux and devcontainers#86
pbendersky wants to merge 1 commit into
BrowserMCP:mainfrom
pbendersky:linux-kill-fix

Conversation

@pbendersky
Copy link
Copy Markdown

This small fix makes browsermcp work properly on Linux, thus enabling it to work on DevContainers.

On macOS lsof -ti:9009 returns an empty string, so xargs interprets that as "no arguments", so no kill is run.

On Linux, however, lsof -ti:9009 returns no output, and xargs still tries to run kill -9, causing an error.

I fixed it with a one-liner that works on both platforms and always exits with 0, so the kill success even if no processes are running.

This enables browsermcp to be used on devcontainers by exposing port 9009, making it suitable to work no more dev environments.

@pbendersky pbendersky changed the title Fixed kill command to work properly on linux Fixed kill command to work properly on linux and devcontainers Jul 11, 2025
internet-dot pushed a commit to internet-dot/mcp that referenced this pull request Apr 6, 2026
- Add live test runs in TME
- Add bicep template for resource deployment
- Simplify testsettings by removing resource name properties
- Auto-generate `.testsettings.json` during resource deployment
- Run unit tests after build
- Run live tests in separate stage
@WeslleyNasRocha
Copy link
Copy Markdown

Confirming this bug still hits on @browsermcp/mcp@0.1.3 (latest) on Linux/WSL2, even when port 9009 is free. The downstream impact is tracked in issues #151, #57, #14, and #37.

The fix in this PR works. As a slightly simpler alternative, GNU xargs supports -r (--no-run-if-empty):

execSync(`lsof -ti:${port} | xargs -r kill -9`);

One-character diff, same behavior on Linux. macOS xargs doesn't support -r, but on macOS the original line already works because BSD xargs doesn't run kill with no input, so the platform branch could even stay split.

Either way — would be great to get this merged so the package works out of the box on Linux. Happy to open a separate PR with the -r variant if it'd help unblock review.

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.

2 participants