From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18003 invoked by alias); 11 Apr 2011 14:34:36 -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: 15951 Received: (qmail 11220 invoked from network); 11 Apr 2011 14:34:21 -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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at vinc17.net does not designate permitted sender hosts) Date: Mon, 11 Apr 2011 16:26:18 +0200 From: Vincent Lefevre To: zsh-users@zsh.org Subject: Re: strange behavior Message-ID: <20110411142618.GA19503@ypig.lip.ens-lyon.fr> Mail-Followup-To: zsh-users@zsh.org References: <20101102120943.GK19295@prunille.vinc17.org> <20101115163234.GE19451@prunille.vinc17.org> <101115092438.ZM29576@torch.brasslantern.com> <20101116031023.GF19451@prunille.vinc17.org> <20110128144412.GA22306@ypig.lip.ens-lyon.fr> <110128074915.ZM5855@torch.brasslantern.com> <20110130003731.GL15921@prunille.vinc17.org> <110130142540.ZM15672@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: <110130142540.ZM15672@torch.brasslantern.com> X-Mailer-Info: http://www.vinc17.net/mutt/ User-Agent: Mutt/1.5.21-6171-vl-r42848 (2011-03-30) On 2011-01-30 14:25:40 -0800, Bart Schaefer wrote: > Possible epiphany: zsh prints "zsh: exit 141" like that only if the > exit status came from a builtin or shell function (Src/exec.c). For > all external commands or subshells it appends the jobtext after the > status number (Src/jobs.c). Those are the only PRINTEXITVALUE cases. > > Thus the exit value of 141 must be coming from one of these places: > > (1) "read" builtin in the inner loop of "filter" > (2) "printf" in the ?* branch of the case in "filter" > (3) "echo" in the { ... } expression I can reproduce the SIGPIPE problem when resizing the terminal window while the wrapper is being run. According to strace, it's (3). > I can't imagine how "read" could return 141. > > For the { echo } statement, I get "zsh: broken pipe" every way I try > to make it fail, before zsh ever gets around to PRINTEXITVALUE. > > That leaves "printf" ... > > Which at first let me to wonder if what's happening is that the inner > while loop is failing to consume the entire svnwrapper:term$'\012' in > a single pass around the outer loop, e.g. that the -t option you're > adding after reading the first character causes read to time out on > some calls instead of reading the next character. But that implies > that the stderr of "filter" is getting closed somehow, and I can't > think of a way that would happen. > > So I'm still stuck. What we need is an "strace -ff -o ..." or the > equivalent to tell which process is printing that, but tracing may > resolve the race condition and prevent the error. Here's the end of the strace output: access("/home/vlefevre/bin/svnwrapper", F_OK) = 0 stat("/home/vlefevre/bin/svnwrapper", {st_mode=S_IFREG|0755, st_size=2027, ...}) = 0 open("/home/vlefevre/bin/svnwrapper", O_RDONLY|O_NOCTTY) = 3 fcntl(3, F_DUPFD, 10) = 11 close(3) = 0 fcntl(11, F_GETFL) = 0x8000 (flags O_RDONLY|O_LARGEFILE) fstat(11, {st_mode=S_IFREG|0755, st_size=2027, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffa4ad2c000 lseek(11, 0, SEEK_CUR) = 0 read(11, "#!/usr/bin/env zsh\n\n# svn wrappe"..., 4096) = 2027 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 pipe([3, 5]) = 0 fcntl(3, F_DUPFD, 10) = 12 close(3) = 0 fcntl(5, F_DUPFD, 10) = 13 close(5) = 0 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7ffa4ad399d0) = 19270 close(12) = 0 fcntl(2, F_DUPFD, 10) = 12 close(2) = 0 dup2(13, 2) = 2 close(13) = 0 rt_sigprocmask(SIG_BLOCK, [CHLD], [CHLD], 8) = 0 rt_sigprocmask(SIG_BLOCK, [CHLD], [CHLD], 8) = 0 pipe([3, 5]) = 0 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7ffa4ad399d0) = 19271 close(5) = 0 read(3, "", 1) = 0 close(3) = 0 rt_sigprocmask(SIG_BLOCK, [CHLD], [CHLD], 8) = 0 rt_sigsuspend([INT]) = ? ERESTARTNOHAND (To be restarted) --- SIGCHLD (Child exited) @ 0 (0) --- --- SIGWINCH (Window changed) @ 0 (0) --- rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1], [INT CHLD WINCH], 8) = 0 rt_sigprocmask(SIG_SETMASK, [INT CHLD WINCH], ~[KILL STOP RTMIN RT_1], 8) = 0 ioctl(10, TIOCGWINSZ, {ws_row=60, ws_col=85, ws_xpixel=523, ws_ypixel=784}) = 0 rt_sigreturn(0x1c) = 0 rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1], [INT CHLD], 8) = 0 rt_sigprocmask(SIG_SETMASK, [INT CHLD], ~[KILL STOP RTMIN RT_1], 8) = 0 wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG|WSTOPPED|WCONTINUED, {ru_utime={0, 0}, ru_stime={0, 0}, ...}) = 19270 wait4(-1, 0x7ffff6dd97ec, WNOHANG|WSTOPPED|WCONTINUED, 0x7ffff6dd9740) = 0 rt_sigreturn(0xffffffff) = -1 EINTR (Interrupted system call) rt_sigprocmask(SIG_BLOCK, [CHLD], [CHLD], 8) = 0 rt_sigsuspend([INT]) = ? ERESTARTNOHAND (To be restarted) --- SIGCHLD (Child exited) @ 0 (0) --- rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1], [INT CHLD], 8) = 0 rt_sigprocmask(SIG_SETMASK, [INT CHLD], ~[KILL STOP RTMIN RT_1], 8) = 0 wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG|WSTOPPED|WCONTINUED, {ru_utime={0, 196012}, ru_stime={0, 204012}, ...}) = 19271 wait4(-1, 0x7ffff6dd97ec, WNOHANG|WSTOPPED|WCONTINUED, 0x7ffff6dd9740) = -1 ECHILD (No child processes) rt_sigreturn(0xffffffff) = -1 EINTR (Interrupted system call) rt_sigprocmask(SIG_BLOCK, [CHLD], [CHLD], 8) = 0 rt_sigprocmask(SIG_UNBLOCK, [CHLD], [CHLD], 8) = 0 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 rt_sigprocmask(SIG_UNBLOCK, [CHLD], [CHLD], 8) = 0 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 dup(2) = 3 fcntl(1, F_DUPFD, 10) = 13 close(1) = 0 dup2(3, 1) = 1 close(3) = 0 write(1, "svnwrapper:term\n", 16) = -1 EPIPE (Broken pipe) --- SIGPIPE (Broken pipe) @ 0 (0) --- +++ killed by SIGPIPE +++ -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)