Skip to content

coder ssh should exit when its parent process dies #1217

@johnstcn

Description

@johnstcn

Problem:

We observed an internal user having a large number of orphaned coder ssh processes running on their laptop.
This was contributing to increased load on coderd.
Our hypothesis is that the user's editor (Cursor) was automatically running a setup script over SSH that invoked coder ssh (via ProxyCommand in .ssh/config) and exiting with an error.

Steps to reproduce:

  1. Run a new shell and get its PID
bash
$ echo $$
12345
  1. SSH into a workspace and run a long-lived command
coder ssh my-workspace sleep infinity
  1. Validate that the coder ssh command is running
ps -eo pid,ppid,command | grep [c]oder
12346 12345 coder ssh my-workspace sleep infinity
  1. Kill the SSH process' parent (the bash shell)
kill -9 12345
  1. Observe the coder ssh process still running but now owned by PID 1
ps -eo pid,ppid,command | grep [c]oder
12346 1 coder ssh my-workspace sleep infinity

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions