0

Hi I'm trying to Implement a IPC in Java with FIFO I cretaed a FIFO with with

mkfifo temp

then I tried to open and FileWriter with

BufferedWriter writeStream = new BufferedWriter(new FileWriter(writePipePath));

but it blocks at this line.

Any idea what the problem could be?

user2071938
  • 2,055
  • 6
  • 28
  • 60
  • 1
    What does your reading code look like? If you have no reader, it should block. – Peter Lawrey Nov 05 '14 at 15:42
  • Thank you very much, thats it! I have 2 pipes for each application(one for sending, one for receiving). But both of the application wanted to open the send Pipe first. – user2071938 Nov 05 '14 at 18:47
  • You could use a Socket and a ServerSocket as this has two streams (one in, one out) will be cleaned up when the program exists, though you will have the same issue ;) – Peter Lawrey Nov 05 '14 at 19:25

1 Answers1

0

As you can read in the mkfifo manual page, opening a fifo will block until both sides are open. FileWriter opens the named pipe synchronously - i.e., it will not return until the pipe is also opened for reading, by another process or another thread.

Guss
  • 30,470
  • 17
  • 104
  • 128