From: Anthony Charles <antho.charles@gmail.com>
To: zsh-users@zsh.org
Subject: Re: Signal handling/zcurses
Date: Thu, 21 Apr 2011 20:08:01 +0200 [thread overview]
Message-ID: <20110421180801.GD6357@layslair.ath.cx> (raw)
In-Reply-To: <110421084717.ZM11635@torch.brasslantern.com>
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
next prev parent reply other threads:[~2011-04-21 18:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-20 10:19 Anthony Charles
2011-04-20 14:40 ` Bart Schaefer
2011-04-20 19:22 ` Anthony Charles
2011-04-21 8:48 ` Bart Schaefer
2011-04-21 14:31 ` Anthony Charles
2011-04-21 15:47 ` Bart Schaefer
2011-04-21 18:08 ` Anthony Charles [this message]
2011-04-22 3:07 ` Bart Schaefer
2011-04-22 5:52 ` Bart Schaefer
2011-04-22 14:22 ` Bart Schaefer
2011-04-27 8:38 ` Anthony Charles
2011-04-21 18:29 ` Anthony Charles
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110421180801.GD6357@layslair.ath.cx \
--to=antho.charles@gmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).