Skip to content

Conversation

@tartarughina
Copy link
Collaborator

Address #41

Implemented a robust cleanup strategy for the spawned LSP process to prevent zombie processes:

  • Added detached: false to the spawn configuration
  • Implemented a cleanup function that attempts a graceful SIGTERM, followed by a forced SIGKILL after 1s if needed
  • Added a listener on stdin end for graceful shutdown
  • Added a watchdog interval to monitor the parent process (PPID); if the parent dies ungracefully, the LSP process will now self-terminate.

Implemented a robust cleanup strategy for the spawned LSP process to
prevent zombie processes:
- Added `detached: false` to the spawn configuration
- Implemented a `cleanup` function that attempts a graceful `SIGTERM`,
  followed by a forced `SIGKILL` after 1s if needed
- Added a listener on `stdin` end for graceful shutdown
- Added a watchdog interval to monitor the parent process (PPID);
  if the parent dies ungracefully, the LSP process will now self-terminate.
@tartarughina
Copy link
Collaborator Author

I've conducted the following testing:

  • Connected to a remote machine via SSH and on TMUX started bottom (btm) to track system resources
  • Connected to the same machine with Zed Remote
  • From TMUX session, verified that Zed spawned the node (proxy) and java (jdtls) processes and logged their PIDs
  • Closed Zed -> node and java processes closed as expected handling the end from stdin
  • Let SSH connection for Zed Remote break -> zombie node and java processes terminated after timeout as PPID no longer present

I've run a similar test on Mac, it appears that the most effective measure here was coming from the watchdog.
I'm unable to test on Windows, so before merging the changes it would be good to have someone trying this out over there.

Copy link
Collaborator

@playdohface playdohface left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good. I don't have Windows running to actually test this, and the whole process-business is very OS-specific so let's make sure we have someone run this on Windows before making it part of a release

@tartarughina
Copy link
Collaborator Author

@playdohface I've added specific Windows handling to the cleanup function, as well as in the watchdog. I've created a Windows VM and I'm going to run some tests over there. If everything works as expected I'll proceed to merge the changes.

@tartarughina tartarughina merged commit 77b7deb into zed-extensions:main Nov 27, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants