I am starting a process in Dart that attaches the stdout stream to stdout so that the results can be printed on the terminal as follows:
Process.start(executable, ['list','of','args']).then((proc) {
stdout.addStream(proc.stdout);
stderr.addStream(proc.stderr);
return proc.exitCode;
});
However, as soon as this ends, I would like to start a new process and start it again (the function it is in will be called several times). Sometimes I get an error message:
Uncaught Error: Bad State: StreamSink is already bound to a stream
Looking at the dart docs, it looks like I might need to do something like stdout.close()or stdout.flush(), but they don't seem to solve the problem. What is the correct way to handle multiple streams in a streamsink-related sequence?
source
share