From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13832 invoked by alias); 21 Apr 2011 18:08:16 -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: 15982 Received: (qmail 12019 invoked from network); 21 Apr 2011 18:08:14 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, T_TO_NO_BRKTS_FREEMAIL autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 74.125.82.43 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=cDOMIjBBSZaEoSnTwFzAvo0KaDbZAt+bLUxG4GFk1PM=; b=ZxK5zLRZQmIflXyQryuFWZ3i5ojyxHxvn3MHNKWmP9jD+OnZT1o+AHhuC0sS+1Xhc3 qLpiVx8RBRbKUAy4GbXP9AjfGkCBaeWx0IqfMzQ2+de9tnBeegCGrn1Sz0nHZigjYfIH x9dTBSXfwoOhOjBnN4ws31gLaOlJ2rUk+SwWk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=xt9TvLSxH9uZshAlF/1ULLnTn8QvnZ19bPRsBd+FxggKK9KEO4HP4d9DdeFnGJMBbl 1eMWhcBpB6P86QKXgQTKA+lOm4vepORx/SkVIUYAww+GZ43rPFPaxF4ea2d1Ktcp6R/9 Y4dOZq7FXHrb838PQus1IaXQAg/GxjKV0EfC4= Date: Thu, 21 Apr 2011 20:08:01 +0200 From: Anthony Charles To: zsh-users@zsh.org Subject: Re: Signal handling/zcurses Message-ID: <20110421180801.GD6357@layslair.ath.cx> References: <20110420101911.GA6357@layslair.ath.cx> <110420074048.ZM16389@torch.brasslantern.com> <20110420192234.GB6357@layslair.ath.cx> <110421014823.ZM17325@torch.brasslantern.com> <20110421143145.GC6357@layslair.ath.cx> <110421084717.ZM11635@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <110421084717.ZM11635@torch.brasslantern.com> User-Agent: Mutt/1.5.21 (2010-09-15) Unforunately, I see no changes with this patch but with little debug, I found out that errno is first set to 4 (EINTR), then wgetch is restarted but failed, errno is set to 0 then my shell while loop breaks and the script terminate. Here's a trace : [...] # refresh_screen is the function tied to USR1 +refresh_screen:28> zcurses move zmpc 0 0 # errno from the while loop in curses.c wgetch -- errno : 4 wgetch -- errno : 0 # end of script, cleaning zcurses +zmpc.sh:250> zcurses delwin zmpc +zmpc.sh:251> zcurses delwin zmpc_status +zmpc.sh:252> zcurses delwin zmpc_currentsong +zmpc.sh:253> zcurses end +zmpc.sh:257> exit 0 Strangely, if I comment my trap and kill -USR1 the script, it terminates immediately, no debug from curses.c as if it didn't receive the signal. On Thu, Apr 21, 2011 at 08:47:15AM -0700, Bart Schaefer wrote: > On Apr 21, 4:31pm, Anthony Charles wrote: > } > } man 3 getch says about wgetch in portability section that it may not > } be interrupted by signals or it may return ERR with errno set to EINTR > } depending of the implementation and OS. In my case, on Debian it > } seems it's the second choice :) > > Try this. > > Index: Src/Modules/curses.c > =================================================================== > --- curses.c 4 Nov 2008 04:47:53 -0000 1.4 > +++ curses.c 21 Apr 2011 15:39:05 -0000 > @@ -1070,7 +1070,11 @@ > #endif > > #ifdef HAVE_WGET_WCH > - switch (wget_wch(w->win, &wi)) { > + while ((errno = 0), (ret = wget_wch(w->win, &wi)) == ERR) { > + if (errno != EINTR) > + break; > + } > + switch (ret) { > case OK: > ret = wctomb(instr, (wchar_t)wi); > if (ret == 0) { > @@ -1092,9 +1096,10 @@ > return 1; > } > #else > - ci = wgetch(w->win); > - if (ci == ERR) > - return 1; > + while ((errno = 0), (ci = wgetch(w->win)) == ERR) { > + if (errno != EINTR) > + return 1; > + } > if (ci >= 256) { > keypadnum = ci; > *instr = '\0'; > > > -- -- Anthony CHARLES