I'm new to java and was trying to read and write to named pipes (created in another native C++ process) using RandomAccessFile. Here's my code :-
String input_pipe = "/home/user/some_pipe";
try {
System.out.println("here1");
RandomAccessFile inp_pipe = new RandomAccessFile(input_pipe, "r");
System.out.println("here2");
} catch (Exception exp) {
System.out.println("Some error opening pipe :- " + exp.getMessage());
}
When I run this code, all I get on the output is :-
here1
And the process just doesn't return. Any tips on what I'm doing wrong or how I can debug this?
Since none of the commenters chose to write an answer, I'll write one myself.
The problem is that opening a named pipe on linux will block until the other end of the pipe has also been opened. You can either open it in non-blocking mode or open both ends of the pipe at once.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.