Is there any difference between C and C++ pipes implementation? Is there any C++ library that makes using pipes easier? I ask those questions because there are many 'wrapper' classes in C++ that wraps C (like string, vector etc.) Is there anything that 'wraps' pipes?

10 Years
Discussion Span
Last Post by Nick Evan

Pipes are part of the POSIX operating system, and nothing to do with the language.

As for classes, maybe - I dunno.
I've reached my google quota for the day.


> Is there anything that 'wraps' pipes?
i do not know of any, but it is very easy to roll out one of our own. eg.

#include <stdio.h>
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/stream.hpp>
#include <fstream>
#include <iostream>
using namespace boost::iostreams ;

struct opipestream : stream< file_descriptor_sink >
  typedef stream< file_descriptor_sink > base ;
  explicit opipestream( const char* command )
    : base( fileno( pipe = popen( command, "w" ) ) ) {}
  ~opipestream() { close() ; pclose( pipe ) ; }
  private : FILE* pipe ;

int main()
  std::cout << "#includes in this file:" << std::flush ;
  std::ifstream fin( __FILE__ ) ;
  opipestream pout( "grep '^#include' | wc -l" ) ;
  pout << fin.rdbuf() ;

// link with libboost_iostreams  eg.
// g++ -Wall -std=c++98 -pedantic -I /usr/local/include -L /usr/local/lib -lboost_iostreams myfile.cc

So... is there anything built into the language (C++) that allows communicating between processes? I can't imagine how it would be done as operating system controls processes, but... is there?


It still depends on what OS you're using, so the answer would be: no, c++ does not have anything standard for that

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.