zsh-workers
 help / color / mirror / code / Atom feed
* zsh 4.3.9: Interrupted "tcsetattr" call problem, tiling-wm related
@ 2009-02-27 16:20 Lionel Flandrin
  2009-03-02 10:23 ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Lionel Flandrin @ 2009-02-27 16:20 UTC (permalink / raw)
  To: zsh-workers

Hi everybody, I haven't subscribed to this list so please include me
in Cc in your replies.

I think I have spotted a bug related to this one:
http://www.zsh.org/mla/workers/2007/msg01121.html

Basically, *sometimes* I get an unusable prompt when I start a new
terminal, if I type <TAB> I get a litteral tab, if I type "key up" I
get ^[[A etc...

A strace told me the problem is that the terminal bufferizes the
output line by line, i.e. is in ICANON termios mode.

A couple of grep and dirty fprintf in the source code later, I think
I've found the root of the problem at Src/utils.c line 1440:

1440          tcsetattr(SHTTY, TCSADRAIN, &ti->tio);
1441      /* if (tcsetattr(SHTTY, TCSADRAIN, &ti->tio) == -1) */

(It's interresting that the bugfix is almost already there :).

Indeed, the problem seems to be that I use a tiling WM (stumpwm) that
resizes the term as soon as it's created, sending (I'm just guessing
there) the SIGWINCH signal to zsh interrupting the tcsetattr.

If I add some debug code:

  while (tcsetattr(SHTTY, TCSADRAIN, &ti->tio) == -1)
  {
     FILE *f = fopen("/tmp/fail.out", "a");
     fprintf(f, "tcsetattr failed: %s\n", strerror(errno));
     fclose(f);
  }

I do get: "tcsetattr failed: Interrupted system call"

If I change the call to:

  while (tcsetattr(SHTTY, TCSADRAIN, &ti->tio) == -1 && errno == EINTR);

It fixes the problem.

I hope this helps.

(Thank to ft on freenode's #zsh for his help).

-- 
Lionel Flandrin


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: zsh 4.3.9: Interrupted "tcsetattr" call problem, tiling-wm related
  2009-02-27 16:20 zsh 4.3.9: Interrupted "tcsetattr" call problem, tiling-wm related Lionel Flandrin
@ 2009-03-02 10:23 ` Peter Stephenson
  2009-03-02 16:01   ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 2009-03-02 10:23 UTC (permalink / raw)
  To: Lionel Flandrin; +Cc: zsh-workers

On Fri, 27 Feb 2009 17:20:25 +0100
Lionel Flandrin <lionel@svkt.org> wrote:
> A couple of grep and dirty fprintf in the source code later, I think
> I've found the root of the problem at Src/utils.c line 1440:
> 
> 1440          tcsetattr(SHTTY, TCSADRAIN, &ti->tio);
> 1441      /* if (tcsetattr(SHTTY, TCSADRAIN, &ti->tio) == -1) */
> 
> (It's interresting that the bugfix is almost already there :).

... just after the line that says "Princeton's include files are screwed
up".  It's interesting we're relying on an ad-hoc fix for a problem
(although not related to this one) on a single system that probably
disappeared ten years ago.

> Indeed, the problem seems to be that I use a tiling WM (stumpwm) that
> If I change the call to:
> 
>   while (tcsetattr(SHTTY, TCSADRAIN, &ti->tio) == -1 && errno == EINTR);
> 
> It fixes the problem.

That looks fine, I've committed it.  Thanks.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: zsh 4.3.9: Interrupted "tcsetattr" call problem, tiling-wm related
  2009-03-02 10:23 ` Peter Stephenson
@ 2009-03-02 16:01   ` Bart Schaefer
  2009-03-02 16:15     ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2009-03-02 16:01 UTC (permalink / raw)
  To: zsh-workers

On Mar 2, 10:23am, Peter Stephenson wrote:
}
} On Fri, 27 Feb 2009 17:20:25 +0100
} Lionel Flandrin <lionel@svkt.org> wrote:
} >   while (tcsetattr(SHTTY, TCSADRAIN, &ti->tio) == -1 && errno == EINTR);
} 
} That looks fine, I've committed it.  Thanks.

I wonder if queue_signals/unqueue_signals around the tcsetattr might be
more appropriate?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: zsh 4.3.9: Interrupted "tcsetattr" call problem, tiling-wm related
  2009-03-02 16:01   ` Bart Schaefer
@ 2009-03-02 16:15     ` Peter Stephenson
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2009-03-02 16:15 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer wrote:
> On Mar 2, 10:23am, Peter Stephenson wrote:
> }
> } On Fri, 27 Feb 2009 17:20:25 +0100
> } Lionel Flandrin <lionel@svkt.org> wrote:
> } >   while (tcsetattr(SHTTY, TCSADRAIN, &ti->tio) == -1 && errno == EINTR);
> } 
> } That looks fine, I've committed it.  Thanks.
> 
> I wonder if queue_signals/unqueue_signals around the tcsetattr might be
> more appropriate?

That doesn't actually block the signal, it just marks that we should
queue any shell code activities.  We would still receive the signal, and
hence the system call would still fail with EINTR.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-03-02 16:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-27 16:20 zsh 4.3.9: Interrupted "tcsetattr" call problem, tiling-wm related Lionel Flandrin
2009-03-02 10:23 ` Peter Stephenson
2009-03-02 16:01   ` Bart Schaefer
2009-03-02 16:15     ` Peter Stephenson

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).