diff --git a/web/ssh-tunnelier b/web/ssh-tunnelier index 6c138e8..47fab70 100755 --- a/web/ssh-tunnelier +++ b/web/ssh-tunnelier @@ -72,7 +72,7 @@ function list_all_ssh() { read -t 600 inputpid [[ "$inputpid" =~ $number_re ]] && { - kill $inputpid + ask_to_kill $inputpid } } @@ -99,6 +99,13 @@ function run_command() { eval $( get_command "$1" ) } +function ask_to_kill() { + printf "${colRow}\nPID: $1\n k kill\n t terminate${colZ}\n" + read -t 600 input2 + [[ "$input2" = "k" ]] && kill $1 + [[ "$input2" = "t" ]] && kill -9 $1 +} + [[ -n "$2" ]] && { run_args "$@" @@ -131,12 +138,9 @@ while true; do this_pid="$( get_pid "${ids[$j]}" )" [[ -n "$this_pid" ]] && { # PID exists, ask to kill - printf "\n ${colRow}k kill\n t terminate${colZ}\n" - read -t 600 input2 - [[ "$input2" = "k" ]] && kill $( get_pid "${ids[$j]}" ) - [[ "$input2" = "t" ]] && kill -9 $( get_pid "${ids[$j]}" ) + ask_to_kill "$this_pid" } - [[ -z "$this_pid" ]] && { + [[ -z "$this_pid" ]] && { # PID empty, run run_command "${ids[$j]}" sleep 1