Closed tengomucho closed 3 years ago
Python needs stdin to be closed before it starts executing commands, just add process.close(reproc::stream::in);
after you've finished writing all the input and it'll work.
I added process.close as you told me, and it exits after the write, but my output string is empty... Furthermore, what if I wanted to keep sending input to the process, could I do it later?
I guess this means sending a newline just isn't sufficient to make the repl interpret the written input from stdin. We would need the correct character sequence to make the python repl progress further to make this work. I'm a bit sceptical whether this is a reproc specific problem. If this is something generic and the solution can be applied to more than just python, I'd be happy to include some helper function to 'flush' the output to the subprocess so it gets interpreted. I checked and we do write all the input correctly to the pipe so that shouldn't be a problem I think.
Closing this one as it's pretty old, feel free to comment if you're still having issues with this
I tried to use the "drain" example to read the output. The idea is to have a program that could send commands to a python REPL and read/parse the output. The problem is that, even if I set the nonblocking option, it seems to get stuck. Note that I have seen the same problem on Linux and Windows. Note that this does not seem to happen if I write my own child process reading input and sending output. Any idea or hint on how to fix that? Here's the code to reproduce it: