-
Notifications
You must be signed in to change notification settings - Fork 106
Closed
Description
#include <subprocess.hpp>
using namespace std;
using namespace subprocess;
int main()
{
vector<Popen> sub_processes;
for ( int i = 0 ; i < 5 ; i++ )
{
sub_processes.emplace_back(Popen({"cat"},input{PIPE}));
sub_processes[i].send("3 5\n", 5);
}
for ( int i = 0 ; i < 5 ; i++ )
{
sub_processes[i].wait(); // waits forever
}
}In the code above I spawn 5 instances of cat. I call send() to each of them.
In the second loop we call wait but it waits forever. I suspect that cat is still waiting for more input because the channel was not closed.
communicate() does close the channels. But I need to use send() is there a function I am missing that can close the channels?
Thanks in advance.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels