Pipes don't serialize or check for things like two readers
and writers. You can have a reader "A" open the pipe with
writer "A", and then switch writers on the reader (by
starting another writer "B" and THEN closing writer "A").
The reader sees an EOF only if a read attempt is made when
no one is WRITING to it. This is further complicated by the
fact that two different processes (Reader and writer) are
not synched in other ways.
I recommend:
- a lock file to make sure two writers don't touch
the pipe at the same time. Make this lock on a separate
lock file (no use locking a pipe you just opened if the
idea is to not touch the pipe before locking).
- Serialize the communications (have each writer use a
unique number). How do you get the unique number? Using
the lock file from (1) could be a solution.
I must admit I did not experiment with your code so there
might be other reasons (but locking is a good idea if you
have the remotest chance that two writers will need to
talk at the same time).
--
termix
-
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.
|