Skip to content

Auto-replace existing daemon using signal-based self-version check #24

Description

@mame

During development or testing, it's often inconvenient that you can't try a new version of wsl2-ssh-agent unless you manually stop the existing daemon process using wsl2-ssh-agent -stop.

I want to add a small hack that uses signal-based communication to detect whether an existing wsl2-ssh-agent process is running and whether it is the same version. Specifically:

  • On startup, if an existing daemon process is found, send SIGUSR1 to that process and wait for SIGUSR2.
  • When SIGUSR1 is received, compute the FNV hash of /proc/self/exe and send SIGUSR2 back to the sender process along with the hash value.
  • When SIGUSR2 is received, compare the hash value with the one computed locally. If they match, exit; if they differ, terminate the existing process with SIGINT and take over as the new daemon.

Since this communication will likely occur on every execution when invoked from .bashrc or similar, we should evaluate the performance impact carefully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions