From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11899 invoked by alias); 2 Jun 2016 09:42:32 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21603 Received: (qmail 11600 invoked from network); 2 Jun 2016 09:42:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-AuditID: cbfec7f4-f796c6d000001486-6f-574ffd286c4d Date: Thu, 02 Jun 2016 10:32:20 +0100 From: Peter Stephenson To: Zsh Users Subject: Re: read still active after Ctrl-C Message-id: <20160602103220.22e3447d@pwslap01u.europe.root.pri> In-reply-to: References: Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrALMWRmVeSWpSXmKPExsVy+t/xq7oaf/3DDdbsZrPYcXIlowOjx6qD H5gCGKO4bFJSczLLUov07RK4MnY1nmEuaOasOHwru4Gxnb2LkZNDQsBE4tuNp0wQtpjEhXvr 2boYuTiEBJYySpza1swK4Uxjkth/dikzhHOaUWL98x1QzhlGiRPH/rGB9LMIqEp87D8AZrMJ GEpM3TSbEcQWEVCUOPPrG9gOYQFtiXdvNzGD2LwC9hLXZ7eC1XAKBEuc/fedFcQWEgiQaJy2 FmwOv4C+xNW/n6Dus5eYeeUMI0SvoMSPyfdYQGxmAS2JzduaWCFseYnNa94yQ8xRl7hxdzf7 BEbhWUhaZiFpmYWkZQEj8ypG0dTS5ILipPRcQ73ixNzi0rx0veT83E2MkHD+soNx8TGrQ4wC HIxKPLwrNP3DhVgTy4orcw8xSnAwK4nwPvwBFOJNSaysSi3Kjy8qzUktPsQozcGiJM47d9f7 ECGB9MSS1OzU1ILUIpgsEwenVANj066N00o+ZTJ8D+d3PnhzuVVDdrKy1KGXfME71U/LF+7J ZBVg1t3yanfs7S/zjrlbsKS9mxLB5tMttWNPxXn2qxmVf8Pmf+V9e01/z0TGZJv1Dys+RoTN E+C6+eLp2axjKmn/JJZFfbn1a8Vf9VXrem80WR/pWyjFPvnV0Z3dd/Pfrlj8kKH1iBJLcUai oRZzUXEiANdka/hjAgAA On Thu, 02 Jun 2016 08:19:56 +0200 Sebastian Gniazdowski wrote: > how to leave whole script on Ctrl-C? Below is a simple example where > read is still active and waits for a key after Ctrl-C is pressed There's a bug here, definitely. As it wasn't entirely clear to me what the result of all those traps was going to be I actually tried it with a simpler trap on SIGINT only. That second catch-all attempt to read from the terminal if the first attempt via select failed was always voodoo. I've a vague feeling it was inspired by playing around on an old SunOS system a good twenty years ago. I'm not sure if this particular cargo cult now needs to be expunged. pws diff --git a/Src/utils.c b/Src/utils.c index 12911d3..95be1fb 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -2534,7 +2534,7 @@ read_poll(int fd, int *readchar, int polltty, zlong microseconds) #endif #endif - if (fd >= 0 && ret < 0) { + if (fd >= 0 && ret < 0 && !errflag) { /* * Final attempt: set non-blocking read and try to read a character. * Praise Bill, this works under Cygwin (nothing else seems to).