Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Named pipes missing connections

by termix (Beadle)
on Dec 24, 2001 at 04:43 UTC ( #134128=note: print w/replies, xml ) Need Help??

in reply to Named pipes missing connections

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

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://134128]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2023-06-07 10:00 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (29 votes). Check out past polls.