[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: manually pipe processes
From: |
Greg Wooledge |
Subject: |
Re: manually pipe processes |
Date: |
Thu, 5 Mar 2009 13:47:00 -0500 |
User-agent: |
Mutt/1.4.2.2i |
On Thu, Mar 05, 2009 at 12:28:00PM -0500, Brian J. Murrell wrote:
> tar cf - /etc | tar xf - | tee /tmp/outfile
> I want (specifically) the second
> tar command to run in the background and I want to wait for it so that
> the "trap" in the parent shell can process signals. Altogether I want:
> #!/bin/bash
> trap 'echo got HUP' HUP
> (tar cf - /etc | tar xf - | tee /tmp/outfile) &
> wait ${pid_of_second_tar}
Something like this, perhaps?
trap ...
fifo=/tmp/fifo.$$ # or mktemp(1) or tempfile(1) etc.
mkfifo $fifo
tee /tmp/outfile < $fifo & teepid=$!
{ tar cf - /etc | tar xf - >$fifo 2>&1 ; } & tarpid=$!
wait $tarpid
That might be a little more heavy-handed than you were looking for,
but since you're already hitting /tmp it shouldn't be terrible to add
a FIFO there.