From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9107 invoked from network); 20 Mar 2009 15:16:50 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 20 Mar 2009 15:16:50 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 83089 invoked from network); 20 Mar 2009 15:16:40 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 20 Mar 2009 15:16:40 -0000 Received: (qmail 28513 invoked by alias); 20 Mar 2009 15:16:23 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13951 Received: (qmail 28502 invoked from network); 20 Mar 2009 15:16:22 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 20 Mar 2009 15:16:22 -0000 Received: from prunille.vinc17.org (vinc17.pck.nerim.net [213.41.242.187]) by bifrost.dotsrc.org (Postfix) with ESMTP id 5234782CF026 for ; Fri, 20 Mar 2009 16:16:18 +0100 (CET) Received: by prunille.vinc17.org (Postfix, from userid 501) id A985134B7D8D; Fri, 20 Mar 2009 16:16:17 +0100 (CET) Date: Fri, 20 Mar 2009 16:16:17 +0100 From: Vincent Lefevre To: Zsh Users List Subject: Re: up-arrow no longer works right Message-ID: <20090320151617.GF22844@prunille.vinc17.org> Mail-Followup-To: Zsh Users List References: <20090320024835.GA64103@redoubt.spodhuis.org> <20090320071556.GA63370@redoubt.spodhuis.org> <20090320133758.GD22844@prunille.vinc17.org> <090320073326.ZM3499@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <090320073326.ZM3499@torch.brasslantern.com> X-Mailer-Info: http://www.vinc17.org/mutt/ User-Agent: Mutt/1.5.19-vl-r28329 (2009-03-19) X-Virus-Scanned: ClamAV 0.92.1/9144/Fri Mar 20 11:51:14 2009 on bifrost X-Virus-Status: Clean On 2009-03-20 07:33:26 -0700, Bart Schaefer wrote: > I'm not sure what you mean by "interpreted by zsh" but this is most > likely a problem with something that's attempting to set the title > bar string of the terminal. This can be reproduced with "zsh -f", and zsh doesn't attempt to change the terminal title. But one may need to use a machine with several processors, so that the race condition can be reproduced (mine has 2 processors). I've looked at strace output and I think I understand what happens: a SIGCHLD interrupts an ioctl system call, which leaves the terminal in an incorrect state. I did: vin:~> strace -t -o strace.out zsh -f vin% emacs file1 ^Z zsh: suspended emacs file1 vin% bg [1] + continued emacs file1 vin% ^[[A^[[A^[[A^[[A^[[B^[[B^[[D^[[C^[[D^[[A^[[B^[[B^[[B^[[B^[[B^[[B^[[A^[[A^[[A^[[A You can see what I get when typing the arrow keys. Here's an excerpt of the strace output: [...] 15:29:04 read(10, "b", 1) = 1 15:29:05 write(10, "b", 1) = 1 15:29:05 read(10, "g", 1) = 1 15:29:05 write(10, "\10bg", 3) = 3 15:29:05 read(10, "\n", 1) = 1 15:29:05 write(10, "\r\n", 2) = 2 15:29:05 alarm(0) = 0 15:29:05 ioctl(10, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig -icanon -echo ...}) = 0 15:29:05 ioctl(10, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) = 0 15:29:05 ioctl(10, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 15:29:05 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 15:29:05 write(10, "[1] + continued emacs file1\n", 30) = 30 15:29:05 kill(4294946362, SIGCONT) = 0 15:29:05 rt_sigprocmask(SIG_BLOCK, [CHLD], [CHLD], 8) = 0 15:29:05 rt_sigprocmask(SIG_UNBLOCK, [CHLD], [CHLD], 8) = 0 15:29:05 ioctl(10, TIOCSPGRP, [20933]) = 0 15:29:05 fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 15), ...}) = 0 15:29:05 fcntl(0, F_GETFL) = 0x8002 (flags O_RDWR|O_LARGEFILE) 15:29:05 geteuid() = 1114 15:29:05 capget(0x20080522, 0, NULL) = -1 EFAULT (Bad address) 15:29:05 capget(0x20080522, 0, {0, 0, 0}) = 0 15:29:05 rt_sigaction(SIGINT, {0x474db0, [], SA_RESTORER|SA_INTERRUPT, 0x7f49a6593190}, NULL, 8) = 0 15:29:05 write(10, "\33[1m\33[7m%\33[27m\33[1m\33[m "..., 101) = 101 15:29:05 rt_sigaction(SIGINT, {0x474db0, [], SA_RESTORER|SA_INTERRUPT, 0x7f49a6593190}, NULL, 8) = 0 15:29:05 geteuid() = 1114 15:29:05 capget(0x20080522, 0, NULL) = -1 EFAULT (Bad address) 15:29:05 capget(0x20080522, 0, {0, 0, 0}) = 0 15:29:05 ioctl(10, FIONREAD, [0]) = 0 15:29:05 ioctl(10, TIOCSPGRP, [20933]) = 0 15:29:05 ioctl(10, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 15:29:05 ioctl(10, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig -icanon -echo ...}) = -1 EINTR (Interrupted system call) 15:29:05 --- SIGCHLD (Child exited) @ 0 (0) --- 15:29:05 rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1], [CHLD], 8) = 0 15:29:05 rt_sigprocmask(SIG_SETMASK, [CHLD], ~[KILL STOP RTMIN RT_1], 8) = 0 15:29:05 wait4(4294967295, 0x7fffaf3a553c, WNOHANG|WSTOPPED, 0x7fffaf3a5310) = 0 15:29:05 rt_sigreturn(0xffffffff) = -1 EINTR (Interrupted system call) 15:29:05 write(10, "\r\33[m\33[27m\33[24m\33[Jvin% ", 22) = 22 [...] Here's the corresponding excerpt in a case where the bug doesn't occur: [...] 15:56:24 read(10, "b", 1) = 1 15:56:24 write(10, "b", 1) = 1 15:56:24 read(10, "g", 1) = 1 15:56:24 write(10, "\10bg", 3) = 3 15:56:24 read(10, "\n", 1) = 1 15:56:25 write(10, "\r\n", 2) = 2 15:56:25 alarm(0) = 0 15:56:25 ioctl(10, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig -icanon -echo ...}) = 0 15:56:25 ioctl(10, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) = 0 15:56:25 ioctl(10, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 15:56:25 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 15:56:25 write(10, "[1] + continued emacs file1\n", 30) = 30 15:56:25 kill(4294942461, SIGCONT) = 0 15:56:25 rt_sigprocmask(SIG_BLOCK, [CHLD], [CHLD], 8) = 0 15:56:25 rt_sigprocmask(SIG_UNBLOCK, [CHLD], [CHLD], 8) = 0 15:56:25 --- SIGCHLD (Child exited) @ 0 (0) --- 15:56:25 rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1], [CHLD], 8) = 0 15:56:25 rt_sigprocmask(SIG_SETMASK, [CHLD], ~[KILL STOP RTMIN RT_1], 8) = 0 15:56:25 wait4(4294967295, 0x7fff6946271c, WNOHANG|WSTOPPED, 0x7fff694624f0) = 0 15:56:25 rt_sigreturn(0xffffffff) = 0 15:56:25 ioctl(10, TIOCSPGRP, [24834]) = 0 15:56:25 fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 7), ...}) = 0 15:56:25 fcntl(0, F_GETFL) = 0x8002 (flags O_RDWR|O_LARGEFILE) 15:56:25 geteuid() = 1114 15:56:25 capget(0x20080522, 0, NULL) = -1 EFAULT (Bad address) 15:56:25 capget(0x20080522, 0, {0, 0, 0}) = 0 15:56:25 rt_sigaction(SIGINT, {0x474db0, [], SA_RESTORER|SA_INTERRUPT, 0x7fb060650190}, NULL, 8) = 0 15:56:25 write(10, "\33[1m\33[7m%\33[27m\33[1m\33[m "..., 101) = 101 15:56:25 rt_sigaction(SIGINT, {0x474db0, [], SA_RESTORER|SA_INTERRUPT, 0x7fb060650190}, NULL, 8) = 0 15:56:25 geteuid() = 1114 15:56:25 capget(0x20080522, 0, NULL) = -1 EFAULT (Bad address) 15:56:25 capget(0x20080522, 0, {0, 0, 0}) = 0 15:56:25 ioctl(10, FIONREAD, [0]) = 0 15:56:25 ioctl(10, TIOCSPGRP, [24834]) = 0 15:56:25 ioctl(10, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 15:56:25 ioctl(10, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig -icanon -echo ...}) = 0 15:56:25 ioctl(10, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig -icanon -echo ...}) = 0 15:56:25 write(10, "\r\33[m\33[27m\33[24m\33[Jvin% ", 22) = 22 [...] -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)