Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Named pipes missing connections

by termix (Beadle)
on Dec 24, 2001 at 04:43 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-19 22:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found