Re: [ILUG] Piping to multiple processes (which might die)?

From: Ronan Cunniffe (ronan at domain cunniffe.net)
Date: Wed 31 Jul 2002 - 15:13:25 IST


Quoting Brian Foster <blf at domain utvinternet.ie>:
> | I did the following:
> |
> 1| $ mkfifo f1
> 2| $ lav2yuv capture.avi | yuvdenoise | tee f1 | mpeg2enc blah blah &
> 3| $ cat f1 | mpeg2enc different blah blah
> |
> | And hey! It works! Until somebody dies! Yippe... oh. [ ... ]
>
> ( a winner of the Useless Use of cat(1) Award: you don't need
> the `cat f1 |' in the 3rd line, a simple `<f1' will suffice. )
Grrr... I've had that bad habit since MS-DOS 3.2

> upshot is a POSIX.2 `tee' would probably spit out an error
> message if one of the `mpeg2enc's dies, but the remaining
> one would continue to be fed data and hence run until it
> either completes or dies for reasons of its own. which is
> exactly what you want! so what is happening??

<contrition>
  Oops.
</contrition>

Um, my test was to tee to a fifo I didn't read from... resulting in the other
reader hanging around forever.... not realising that never-opened-for-reading
and opened-and-later-closed might be different. Sensible behaviour has now been
observed.
 
> incidently, if your shell and system both support process
> redirection, you could do the above as a one-liner. syntax
> varies depending on the shell, but in bash(1) and ksh(1):
>
> lav2yuv capture.avi | yuvdenoise | \
> tee >(mpeg2enc different blah blah) | mpeg2enc blah blah
mpeg2enc generates stats during the run, so I give each one an xterm.

Thanks,
Ronan



This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:18:07 GMT