cpp-subprocess/test/test_ret_code.cc
okaymaged 7534a9cddb Don't waitpid on SIGCHLD, which lost the retcode (#11)
* Don't waitpid on SIGCHLD, which lost the retcode

* Adding test
2018-03-02 20:28:24 +05:30

19 lines
316 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({"/bin/false"});
while (p.poll() == -1) {
usleep(1000 * 100);
}
assert (p.retcode() == 1);
}
int main() {
test_ret_code();
}