zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: strange behavior
Date: Sun, 30 Jan 2011 14:25:40 -0800	[thread overview]
Message-ID: <110130142540.ZM15672@torch.brasslantern.com> (raw)
In-Reply-To: <20110130003731.GL15921@prunille.vinc17.org>

On Jan 30,  1:37am, Vincent Lefevre wrote:
} Subject: Re: strange behavior
}
} On 2011-01-28 07:49:15 -0800, Bart Schaefer wrote:
} > There has to be some kind of race condition here.  2>>(filter) runs
} > filter in the background, so if something behind svn also runs as an
} > separate process, it could be possible for the filter to exit and
} > close it's stdin (thereby closing everything else's stdder) before
} > operating-system-level exit-time buffer-flushing has finished.
} 
} Yes, this happens, but I don't see why this could make the script
} terminate with a broken pipe.

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

} Note that when I obtained the "zsh: exit 141", the svn output wasn't
} redirected, so that a "Broken pipe" message from svn was not possible.

I don't understand what "wasn't redirected" means.  Stderr is always
redirected; "Broken pipe" could occur if svn prints something to
stderr after 2>>(filter) has exited.  I still can't figure out how
to tie that to "zsh: exit 141" given the constraints above, though.

} > Hmm, another thought ... maybe the "zsh: exit 141" is coming from
} > the shell's exit-time handling of the "filter" program, rather than
} > from svn.  I've lost enough context here that I don't recall whether
} > that was previously ruled out too.
} 
} What do you mean here?

I meant that 2>>(...) is handled specially.  Because "filter" is a
shell function, it runs in a subshell which might have inherited the
printexitvalue setopt from its parent.  When filter exits inside the
subshell, perhaps the subshell is printing "exit 141" before it also
exits.  *That* could correspond to printf barfing, but what would be
closing the stderr of the command substitution?


  reply	other threads:[~2011-01-30 22:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-02 12:09 Vincent Lefevre
2010-11-15 16:32 ` Vincent Lefevre
2010-11-15 17:24   ` Bart Schaefer
2010-11-16  3:10     ` Vincent Lefevre
2011-01-28 14:44       ` Vincent Lefevre
2011-01-28 15:49         ` Bart Schaefer
2011-01-30  0:37           ` Vincent Lefevre
2011-01-30 22:25             ` Bart Schaefer [this message]
2011-01-31  9:11               ` Vincent Lefevre
2011-04-11 14:26               ` Vincent Lefevre
2011-04-11 14:39                 ` Vincent Lefevre
2011-04-11 15:15                   ` Peter Stephenson
2011-04-28 11:32                     ` Vincent Lefevre

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=110130142540.ZM15672@torch.brasslantern.com \
    --to=schaefer@brasslantern.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).