This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ctrl-c not working


ctrl-d doesn't work?

Sent from my iRon

On Sep 19, 2014, at 17:51, "Thomas Schweikle" <tschweikle@gmail.com> wrote:

Having following scripts:

bin/tc:
--- <snip>
#!/usr/bin/bash

host=""
loop=0
conf=default
port=22
user=$USERNAME
cssh=1
cping=1
recon=0

while [ -n "$1" ]; do
 case "$1" in
   -f)     conf="$2";      shift ;;
   -h)     host="$2";      shift ;;
   -l)     loop=1                ;;
   -nping) cping=0               ;;
   -nssh)  cssh=0                ;;
   -p)     port="$2";      shift ;;
   -u)     user="$2";      shift ;;
   *)      echo "$0: Error: Unknown option: \"$1\"!" ;;
 esac
 shift
done

if [ -e $conf ]; then
 conf="$PWD/$conf"
elif [ -e $HOME/.mintty/$conf ]; then
 conf="$HOME/.mintty/$conf"
else
 echo "$0: Error: Unknown config-file: \"$conf\" - not found in
\"$PWD\"; \"$HOME/.mintty\"!"
fi

mintty -s 132,43 -t "${user}@${host}" \
 -c "${conf}" \
 -e _ssh "$user" "$host" "$port" "$conf" "$loop" "$cssh" "$cping" &
--- <snap>

and bin/_ssh:
--- <snip>
#!/usr/bin/bash

user=$1
host=$2
port=$3
conf=$4
loop=$5
cssh=$6
cping=$7

while :; do
 printf '\x2d %s ssh connect ' ${host}
 if [ "$host" == "localhost" ]; then
   exec /usr/bin/bash -l
 else
   while :; do
     if [ $cping -ne 0 ]; then
       if ( ! ping -n 1 ${host} > /dev/null 2>&1 ); then
         printf '.'
sleep 1
         continue
       fi
     fi
     if [ $cssh -ne 0 ]; then
       if ( ! nc -z ${host} ${port} > /dev/null 2>&1 ); then
         printf '/'
sleep 1
         continue
       fi
     fi
     break
   done
   printf '\n'
   /usr/bin/ssh \
     -o UserKnownHostsFile=/dev/null \
     -o StrictHostKeyChecking=no -X -K \
     -p ${port} \
     -l ${user} ${host}
   [[ $loop -eq 0 ]] && break
   printf 'Reconnecting ...'; sleep 3
   printf '\n'
 fi
done
--- <snap>

started by:
C:\cygwin\bin\bash.exe -l -c "tc -f tpstest -l -u root -h fbsd12-64"

does what it is expected to do: starting mintty, then checking
reachability of the given host. If the host is reachable ssh is
started and connects to the host. If the host is gonig down
intentionally or not, it tries again to reach the host and if it is
reachable connects again to it.

Now if I type ctrl-c while trying to connect nothing happens. But I'd
like the script to bail out, terminating. But nothing works: ctrl-c
doesn't ctrl-z doesn't. I only can kill -9 the bash associated with
it.
How do I get ctrl-c to work?

-- 
Thomas

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]