Skip to content

SSH process for port redirection should be terminated properly  #244

Description

@hikalium

sometimes the child processes (for ssh port forwarding) do not terminate properly and keep listening to the port to be forwarded, which can use up all the available ports eventually. We should investigate why it happens and fix that for most of the cases.

For now, you can run this script in the background to kill the stale processes periodically:

function clean_defunct_ssh_processes() {
  cat /proc/1/task/*/children | sed 's/ /\n/g' | xargs -I {} -- grep -a --with-filename '^ssh$' /proc/{}/comm /proc/{}/cmdline | cut -d '/' -f 3 | xargs -I {} -- bash -c "echo {}; kill {}"
}

for ((i = 1; 1; i++)); do
        clean_defunct_ssh_processes
        echo "Done. Next run will be in 5 min..."
        sleep 300
done

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1Finish this cycle

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions