mirror of
https://github.com/arun11299/cpp-subprocess.git
synced 2025-08-05 12:56:23 -04:00

* windows: add util functions * windows: add cmake files * windows: add travis.yml * windows: address compatibility - set cxx standard - conditionally exclude codecvt * windows: improve test coverage * windows: improve test coverage * windows: consolidate tests * windows: disable failing test * windows: modify read_atmost_n to use file object * windows: modify read_all to use file object * windows: update read_all test to use new api * windows: implement main subprocess logic * windows: add macro names * windows: setup comm channels * windows: compatibility fixes
34 lines
779 B
C++
34 lines
779 B
C++
#include <iostream>
|
|
#include "../subprocess.hpp"
|
|
|
|
namespace sp = subprocess;
|
|
|
|
void test_ret_code()
|
|
{
|
|
std::cout << "Test::test_poll_ret_code" << std::endl;
|
|
auto p = sp::Popen({"/usr/bin/false"});
|
|
while (p.poll() == -1) {
|
|
usleep(1000 * 100);
|
|
}
|
|
assert (p.retcode() == 1);
|
|
}
|
|
|
|
void test_ret_code_comm()
|
|
{
|
|
using namespace sp;
|
|
auto cat = Popen({"cat", "../subprocess.hpp"}, output{PIPE});
|
|
auto grep = Popen({"grep", "template"}, input{cat.output()}, output{PIPE});
|
|
auto cut = Popen({"cut", "-d,", "-f", "1"}, input{grep.output()}, output{PIPE});
|
|
auto res = cut.communicate().first;
|
|
std::cout << res.buf.data() << std::endl;
|
|
|
|
std::cout << "retcode: " << cut.retcode() << std::endl;
|
|
}
|
|
|
|
int main() {
|
|
// test_ret_code();
|
|
test_ret_code_comm();
|
|
|
|
return 0;
|
|
}
|