I need to pass commands to a process on subprocess.Popen()
but when I do, it only works if I use stdin.close()
afterwards. My code is below.
sprocess.stdin.write('/stop'.encode())
sprocess.stdin.flush()
sprocess.stdin.close()
sprocess.stdout.close()
Works, but that is because of stdin.close()
and I need to be able to do this without closing the pipes.
How can I pass commands to the process without closing the pipes after?
Note that sprocess.stdin.write('/stop'.encode())
will not add a newline! Your subprocess is probably expecting a line of input, signified by either a newline or EOF. Closing stdin
will send that EOF.
Try sending sprocess.stdin.write('/stop\n'.encode())
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With