cpp-subprocess/test/test_subprocess.cc
2016-03-16 14:14:11 +05:30

19 lines
376 B
C++
Executable File

#include <iostream>
#include "../subprocess.hpp"
using namespace subprocess;
void test_input()
{
auto p = Popen({"grep", "f"}, output{PIPE}, input{PIPE});
const char* msg = "one\ntwo\nthree\nfour\nfive\n";
p.send(msg, strlen(msg));
auto res = p.communicate(nullptr, 0);
std::cout << res.first.buf.data() << std::endl;
}
int main() {
test_input();
return 0;
}