Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> So do modern Linux pipes work bi-directionally?

No, they do not (nor on the modern BSD kernels, as far as I can tell). The Linux pipe(7) manpage says (under "Portability notes"):

    «On some systems (but not Linux), pipes are bidirectional:
    data can be transmitted in both directions between the
    pipe ends. POSIX.1 requires only unidirectional pipes.
    Portable applications should avoid reliance on
    bidirectional pipe semantics.»
I believe the systems that supported bidirectional pipes were SysV kernels that implemented pipes using STREAMS and 4(?)BSD kernels that implemented it using socketpair.


Sorry, I was wrong about the BSDs. FreeBSD's pipe.2 manpage clearly says that pipes are still bidirectional. https://www.freebsd.org/cgi/man.cgi?query=pipe&sektion=2

That said, it is not based on socketpair any more. sys/kern/sys_pipe.c says:

    /*
     * This file contains a high-performance replacement for the socket-based
     * pipes scheme originally used in FreeBSD/4.4Lite.  It does not support
     * all features of sockets, but does do everything that pipes normally
     * do.
     */




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: