> From: Andreas Schwab <[SNIP]> > Subject: Re: mkfifo and tee within a function > Sent: 2006-11-28 15:09 > > Nathan Coulter <[SNIP]> writes: > > > Could anyone please provide a few pointers on how to accomplish this, and > perhaps explain the results from the above examples? > > A process writing to a pipe that has no reader will receive EPIPE/SIGPIPE > and die thereof by default. So it all depends on timing. >
I think that is true for an anonymous pipe, but not for a named pipe. Timing is not the issue here. A command which opens a named pipe for writing should block until a reader comes online. In the following example, I get an error with "source', but not with "cat". Why? $>cmd_print () { mkfifo zout; tee zout & cat zout >/dev/null ; rm zout; } $>cmd_print <<EOF > date > EOF [1] 5263 date [1]+ Done tee zout $>cmd_print () { mkfifo zout; tee zout & source zout ; rm zout; } $>cmd_print <<EOF > date > EOF [1] 5267 $>date tee: zout: Broken pipe Finally, my workaround to this is: $>cmd_print () { mkfifo zout; tee zout & eval "$(cat zout)" ; rm zout; } $>cmd_print <<EOF > date > EOF [1] 5274 date Tue Nov 28 11:21:19 CST 2006 [1]+ Done tee zout $> -- Nathan Coulter _______________________________________________ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash