I'm trying to use subprocess to open another process which should be alive while my main process is running. This main process would send some commands to that subprocess. However, when i use a pipe to communicate with that subprocess it also adds an eot(End Of Transmission) char, which is usually terminating char for processes in linux based os.
my_subprocess = subprocess.Popen("python", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
my_subprocess.stdin.write("print 2+2\n")
stdout, stderr = my_file.communicate()
my_subprocess.stdin.write("print 3+5\n")
The first call generates a ^D, which is a termination char for python shell. Therefore, i get an error like this:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: I/O operation on closed file
Is there a way to use subprocess for this purpose?