X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:message-id:content-type
	:content-transfer-encoding:subject:references:from:mime-version
	:in-reply-to:date:to:cc; q=dns; s=default; b=YwISI9FqiJZQC5vxfID
	c7TvBIPeztCauHfbeUieEOuln5QbpDxNM7k5MCidu/A9x3bX79ZTJ28fcJGw0VCB
	F9NLebV4dnNe3aKOuq9LLGoWDdXprTAaKb7N1FWgEuSuZJVouuubSCEDrvmONjmO
	xB8gbyEhkSOURm/rvS/2YMho=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:message-id:content-type
	:content-transfer-encoding:subject:references:from:mime-version
	:in-reply-to:date:to:cc; s=default; bh=EkuAj5apsnre/U4mG9ohSFO/x
	a4=; b=ELvY6URg0wHCAamJg0/0ZqjHQvMy4EcRcf3qaRwnP6ztD0zYgzxv3d5zl
	gYtWZbTAKNdGC4i/FdIu5MyAhMeCRhB8du/HnSKkJGLK1/fPm+zLQvX112QEan/X
	IVJpvLtsvJrFllRS9g5+zarc8Ys0w7ul7V+jyj2YRPfaVA8iY4=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=0.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2
X-HELO: DUB004-OMC1S26.hotmail.com
X-TMN: [G0Yq7dY38zZQN/ZNprFqYZcRvJ78fXsm]
Message-ID: <DUB408-EAS192512638D3E2B15945A1CB0B40@phx.gbl>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Subject: Re: ctrl-c not working
References: <CA+rGx5fDntZ-7ge-ucPvygPJ6tAC93DFvHd1UbM6=AUVjxJW7w@mail.gmail.com>
From: "Gery ." <gamejihou@hotmail.com>
MIME-Version: 1.0 (1.0)
In-Reply-To: <CA+rGx5fDntZ-7ge-ucPvygPJ6tAC93DFvHd1UbM6=AUVjxJW7w@mail.gmail.com>
Date: Fri, 19 Sep 2014 19:13:13 +0200
To: Thomas Schweikle <tschweikle@gmail.com>
CC: "cygwin@cygwin.com" <cygwin@cygwin.com>
X-IsSubscribed: yes

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

