I'd like to create a named pipe, like the one created by "mkfifo", but one caveat. I want the pipe to be bidirectional. That is, I want process A to write to the fifo, and process B to read from it, and vice-versa. A pipe created by "mkfifo" allows process A to read the data its written to the pipe. Normally I'd use two pipes, but I am trying to simulate an actual device so I'd like the semantics of open(), read(), write(), etc to be as similar to the actual device as possible. Anyone know of a technique to accomplish this without resorting to two pipes or a named socket?
Asked
Active
Viewed 4,603 times
2 Answers
6
Or pty
("pseudo-terminal interface"). man pty
.

liori
- 40,917
- 13
- 78
- 105
-
4A pty comes with a bunch of stuff that you don't want - usually. Like all the terminal discipline handling. But it is thinking outside the box to mention it. – Jonathan Leffler Aug 31 '09 at 18:36
5
Use a Unix-domain socket.
Oh, you said you don't want to use the only available solution - a Unix-domain socket.
In that case, you are stuck with opening two named pipes, or doing without. Or write your own device driver for them, of course - you could do it for the open source systems, anyway; it might be harder for the closed source systems (Windows, AIX, HP-UX).

Jonathan Leffler
- 730,956
- 141
- 904
- 1,278