Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Mixing and multiple redirection of stderr/stdout
- X-seq: zsh-users 16045
- From: Aaron Davies <aaron.davies@xxxxxxxxx>
- To: "zsh-users@xxxxxxx" <zsh-users@xxxxxxx>
- Subject: Re: Mixing and multiple redirection of stderr/stdout
- Date: Wed, 18 May 2011 13:33:06 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=bNwUN4pO2Z5BBmXn37KcDEDqCUmDvPjPACLe0AL+HoQ=; b=GiriA1TDKQJINxJ1vC6AM56c2/ZHSK/YmMg1xPlk0VyTYGXcpPpkW29aySKW8JLDuB M8KIfZZ0S4VjfD+qSJgpZ+GJ4UU9z/petnq/ldKa7OptHQ2OkHShhWy3tkLsRsB3yx2O OTTnW2QxKWS+vYOhu3OhTrxZkL+3mX9EaqJtk=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=hqhW6mOzlF1hz1SzrEcrXBCiEtD/wzIWr75CmZ7oysWu+akaz0/9+aezgDjesHAEwx hx0439KGeRwbswH06PHIZvRvOUAagnLDMPMD7EJzMuK1CSAZKHlcoG4CBSjzz83xJf3P O1ShMDjKCg9v5u1WhZqnPcVtz3cVULvRFB/U4=
- In-reply-to: <110518072636.ZM17380@torch.brasslantern.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <11397254-2D05-4778-8FFC-EA2CCAEA040F@uni-ulm.de> <110517195642.ZM16352@torch.brasslantern.com> <BANLkTimP=J4Q1xxCpPmSPpYVMBATR6sLdQ@mail.gmail.com> <E1C4E54E-1CA4-47B4-9FE9-6A29ACB094B0@uni-ulm.de> <110518072636.ZM17380@torch.brasslantern.com>
On Wednesday, May 18, 2011, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On May 18, 11:18am, Michael Lehn wrote:
> }
> } Am 18.05.2011 um 07:13 schrieb Aaron Davies:
> }
> } > Relatedly, can these (or any other) redirections guarantee the
> } > same interleaving of stdout and stderr that would be produced on
> } > the console with no redirections? I've often seen (mostly in other
> } > shells, iirc) that a process which would have, e.g., alternating
> } > prints to out and err, is captured to file as one long block of out
> } > followed by one long block of err.
> }
> } So can something like my "mixing stdout&stderr but also redirect
> } stdout, stderr separately to files" work at all? The longer I think
> } about it the more I am confused how it could be realized technically.
> } I guess it can not be done by using "open, close, dup and co"
> } internally. Or am I wrong?
>
> In fact under the covers zsh is arranging something similar to
>
> exec 3>file_mix
> { script.sh |
> tee -a /proc/fd/3 |
> cat > file_out } 2>&1 |
> tee -a /proc/fd/3 |
> cat > file.err
>
> so there is pipe buffering introduced that can affect the order of the
> output in the mixed file even though the file is opened only once.
>
> Even with >file_mix 2>&1 though, the order of output in the file can
> be different from the order of output to the terminal because the
> default OS buffering strategy for file descriptors may differ based
> on the kind of device being written. The introduction of extra pipes
> just exaggerates this effect.
>
> On the other hand zsh's internal tee/cat analogs are optimized for
> efficiency rather than for preservation of ordering. They could be
> redone using select() and non-blocking descriptors to create a much
> closer approximation of the interleaved write.
I guess for now the best option is to capture at some other layer
(screen, the terminal, etc....)
--
Aaron Davies
aaron.davies@xxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author