There is a contract for the use of a named pipe. I will suppose un*xlike and to simplify I will not talk about non-blocking. For pipes the
default is blocking.
You need a reader and usually the reader is a long-running process.
The reader will block on read as soon as it opens.
If there is no reader any writer will block.
Remember it *is* a pipe so what gets in must get out...
If you write more than a certain maximum number of bytes input is likely to be intermixed between the writers.
If the reader does not process the input quickly enough then eventually a writer will be blocked and then all the other writers, so you need some flow analysis or special janitor processes.
So do you have a permanent reader? If you have a read-once reader
the behavior you seem to be experiencing is *normal*.
Can it be somehow that the pipe is opened by the two threads?
Can you check with lsof or similar the processes that maintain a descriptor opened to the named pipe.
If you had posted some code we might have been able to help better.
% steph@ape (/home/stephan) %
% cat reader.sh
#!/bin/ksh
trap 'exit 0' INT
pipe=named_pipe outfile=out
[[ -p $pipe ]] || mkfifo $pipe
exec 0<$pipe
while dd if=$pipe bs=64 count=1 >> $outfile
do
print .processing
sleep 2
done
% steph@ape (/home/stephan) %
% jobs
[1] + Running ./reader.sh &
cheers --stephan
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|