Zsh Mailing List Archive
Messages sorted by:
Re: piping stderr
- X-seq: zsh-users 14121
- From: Atom Smasher <atom@xxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: piping stderr
- Date: Fri, 15 May 2009 23:47:34 +1200 (NZST)
- In-reply-to: <691a5d910905140904p538d5343md0712590db983853@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Openpgp: id=0xB88D52E4D9F57808; algo=1 (RSA); size=4096; url=http://atom.smasher.org/pgp.txt
- References: <20090514104908.98556.qmail@xxxxxxxxxxx> <691a5d910905140904p538d5343md0712590db983853@xxxxxxxxxxxxxx>
On Thu, 14 May 2009, Bart Schaefer wrote:
On Thu, May 14, 2009 at 3:49 AM, Atom Smasher <atom@xxxxxxxxxxx> wrote:
i'd like to pipe all stderr from a script into a command to do logging...
but this isn't synchronous:
exec 2> >( multilog /path/ )
i need it to be synchronous so that multiple scripts running at the
same time (and also logging debug messages) can all log together and
not clobber each others output.
I'm not sure what you think "synchronous" implies here. Within a
particular "instance" of zsh, such as a single running script, commands
can be synchronous in the sense that zsh waits for the command to finish
before going on to the next one. However, multiple scripts "running at
the same time" already implies that the zsh instances are asynchronous
with respect to one another, so no command started by a particular zsh
instance will be synchronous with respect to other instances (unless you
employ some sort of external locking scheme, but then you're just
preventing the scripts from "running at the same time").
among different scripts (different invocations of the same script) things
are wildly asynchronous. but within each script, which is logging debug
output into multilog, i want to make sure that the stderr and debug
messages appear in the right order. this script shows how that doesn't
exec 2> >(rot13)
the "dattxxx" commands are there to produce "command not found" errors on
stderr. with zsh 4.2.1 the redirect into a coproc makes it just hang.
That said ... have you tried your example above? I'd be mildly
surprised if multilog doesn't already do something to assure that
multiple loggers don't clobber one another's output. They might
intermingle their output, in which case you need to tag each line of it
with a PID or some such, but Dan Bernstein is generally pretty
compulsive about preventing data loss.
if there's one thing multilog does, it makes sure that multiple inputs
don't clobber each other. i am tagging each line with a PID so i can grep
out a particular process and see what's going on.
the problem i'm seeing with the script above, and variations on it, is
that sometimes the output is in the right order, but sometimes all of
stdout appears, followed by all of stderr.
762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808
"HEY! HO! LET'S GO!"
-- The Ramones
Messages sorted by: