coder / coder/internal

`coder ssh` should exit when its parent process dies

Open
#1,217 4 comments 0 reactions 1 assignee Claimed by @johnstcn View on GitHub
Dominant language
No language data
Stars
3
Forks
0
PR merge metrics
No merged PRs in 30d

Description

**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
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.