Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • 2
    On many systems, Linux being a notable exception, pipes are bidirectional though. A socketpair() is a more portable way to have a bidirectional pipe (note that ksh93 uses a socketpair() for its | operator but shuts down the reverse direction). Commented Nov 13, 2017 at 17:37
  • Could you send a file descriptor or some address from foo.js to bar.js via stdio and then bar could write to foo that way? Commented Nov 13, 2017 at 17:45
  • I added an answer to explain how you could do this with *nix, but not sure if it's as easy on MacOS...I have to support MacOS and on the latter, I think you need to create your own FIFO to do this. Commented Nov 13, 2017 at 18:36
  • @StéphaneChazelas a socketpair() is not a pipe, the two are not the same thing. A socketpair() is closer to a Unix Domain Socket instead. Also, do you have a source on your "pipes are bidirectional" claim? They're not meant to be. Commented Nov 24, 2017 at 11:49
  • @WouterVerhelst, no, socketpairs are not pipes, but can be used in places of pipes for the shell | (also called pipe) operator. That's what ksh93 does on Linux at least as said above). Pipes are bidirectional on at least FreeBSD and Solaris and I'd expect all SysV derived Unices and probably all BSDs, though I've only tested on FreeBSD and Solaris. That's clearly documented on FreeBSD and on Solaris Commented Nov 24, 2017 at 12:29