[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: mkfifo and tee within a function
From: |
Poor Yorick |
Subject: |
Re: mkfifo and tee within a function |
Date: |
Tue, 28 Nov 2006 17:04:18 +0000 |
> From: Andreas Schwab <schwab@suse.de>
> Subject: Re: mkfifo and tee within a function
> Sent: 2006-11-28 15:09
>
> Nathan Coulter <org.gnu.lists.bug-bash@pooryorick.com> 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. 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 & sleep 2; cat zout ; rm zout; }
$>cmd_print <<EOF
> date
> EOF
[1] 5167
date
date
[1]+ Done tee zout
$>cmd_print () { mkfifo zout; tee zout & sleep 2; source zout ; rm zout; }
$>cmd_print <<EOF
> date
> EOF
[1] 5174
date
tee: zout: Broken pipe
$>
--
Nathan Coulter