Why doesn't this code work in Linux (Ubuntu) ? I'm trying to run "ls -al" (the Linux ls command)
#include <boost/process.hpp>
#include <boost/system/error_code.hpp>
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/asio.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <string>
#include <istream>
#include <cstdlib>
#include <iostream>
int main(int argc, char* argv[])
{
bp::pipe p = bp::create_pipe();
{
bio::file_descriptor_sink sink(p.sink, bio::close_handle);
boost::system::error_code ec;
bp::execute(
bpi::run_exe("ls"),
bpi::set_cmd_line(" -al"),
bpi::bind_stdout(sink),
bpi::set_on_error(ec)
);
// BOOST_CHECK(!ec);
}
bio::file_descriptor_source source(p.source, bio::close_handle);
bio::stream<bio::file_descriptor_source> is(source);
std::string s;
is >> s;
cout << "here " << s << endl;
}
On Wednesday, August 31, 2016 11:03 AM, Shubha Ramani <shubharamani@yahoo.com> wrote:
on Linux.
This code hangs at getline. I replaced "test.exe" with "ls". Why doesn't it work ?