mirror of
https://github.com/arun11299/cpp-subprocess.git
synced 2025-08-05 04:46:21 -04:00
I can send() but I have no way of closing the input channel #21
This commit is contained in:
parent
a90174cf5c
commit
ced3d53e3a
@ -1012,6 +1012,11 @@ public:
|
|||||||
FILE* output() { return stream_.output();}
|
FILE* output() { return stream_.output();}
|
||||||
FILE* error() { return stream_.error(); }
|
FILE* error() { return stream_.error(); }
|
||||||
|
|
||||||
|
/// Stream close APIs
|
||||||
|
void close_input() { stream_.input_.reset(); }
|
||||||
|
void close_output() { stream_.output_.reset(); }
|
||||||
|
void close_error() { stream_.error_.reset(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename F, typename... Args>
|
template <typename F, typename... Args>
|
||||||
void init_args(F&& farg, Args&&... args);
|
void init_args(F&& farg, Args&&... args);
|
||||||
|
@ -1 +1 @@
|
|||||||
through stdin to stdoutthrough stdin to stdoutthrough stdin to stdoutthrough stdin to stdout
|
through stdin to stdout
|
@ -23,6 +23,24 @@ void test_cat_file_redirection()
|
|||||||
std::cout << "END_TEST" << std::endl;
|
std::cout << "END_TEST" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_cat_send_terminate()
|
||||||
|
{
|
||||||
|
std::cout << "Test::test_cat_send_terminate" << std::endl;
|
||||||
|
std::vector<sp::Popen> pops;
|
||||||
|
|
||||||
|
for (int i=0; i < 5; i++) {
|
||||||
|
pops.emplace_back(sp::Popen({"cat", "-"}, sp::input{sp::PIPE}));
|
||||||
|
pops[i].send("3 5\n", 5);
|
||||||
|
pops[i].close_input();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=0; i < 5; i++) {
|
||||||
|
pops[i].wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "END_TEST" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
void test_buffer_growth()
|
void test_buffer_growth()
|
||||||
{
|
{
|
||||||
auto obuf = sp::check_output({"cat", "../subprocess.hpp"});
|
auto obuf = sp::check_output({"cat", "../subprocess.hpp"});
|
||||||
@ -40,9 +58,12 @@ void test_buffer_growth_threaded_comm()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
test_cat_pipe_redirection();
|
// test_cat_pipe_redirection();
|
||||||
|
test_cat_send_terminate();
|
||||||
|
/*
|
||||||
test_cat_file_redirection();
|
test_cat_file_redirection();
|
||||||
test_buffer_growth();
|
test_buffer_growth();
|
||||||
test_buffer_growth_threaded_comm();
|
test_buffer_growth_threaded_comm();
|
||||||
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user