views:

660

answers:

2

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?

+1  A: 

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
+1  A: 

Or pty ("pseudo-terminal interface"). man pty.

liori
A 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