Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Signal handling/zcurses
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author