Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: piping stderr



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").

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.



Messages sorted by: Reverse Date, Date, Thread, Author