Boost logo

Boost :

Subject: Re: [boost] How to bind program termination with end-of-stream in Boost.Process 0.5?
From: Boris Schaeling (boris_at_[hidden])
Date: 2012-09-16 14:53:12

On Sun, 16 Sep 2012 05:29:29 +0200, alfC <alfredo.correa_at_[hidden]> wrote:

> [...]ok, thanks for the info. Is that a question for me? I am not
> familiar
> with these objects. Also I use Linux only for development. These
> objects didn't seem to be necessary in Boost.Process GSOC2010.

That's true (I see you are familiar with previous versions :). We had a
handle type which was defined by Boost.Process. We also had stream types
like pistream and postream. All of this has been replaced with types from
Boost.Iostreams. We could still define all of this in Boost.Process
theoretically. But I think it makes more sense if we reuse other Boost
libraries and concentrate in Boost.Process on what that library really is
about (especially after working on it for six years ;).

> [...]ok, since there is no conclusive solution, so maybe to end this
> thread
> let me file this as a possible bug (or confirm it is the expected
> behavior), the symptom is that the program never ends (linux, fedora
> 17, boost 1.48):

Can you try this program? It works for me:
#include <boost/process.hpp>
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/stream.hpp>
#include <string>

using namespace boost::process;
using namespace boost::process::initializers;
using namespace boost::iostreams;

int main()
   boost::process::pipe p = create_pipe();
     file_descriptor_sink sink(p.sink, close_handle);
     execute(run_exe("/bin/ls"), bind_stdout(sink));
   file_descriptor_source source(p.source, close_handle);
   stream<file_descriptor_source> is(source);
   std::string s;
   while(std::getline(is, s)){
     std::cout << "read: " << s << std::endl;
   std::clog << "end" << std::endl;


> [...]

Boost list run by bdawes at, gregod at, cpdaniel at, john at