I'm using python right now. I have a thread that represents my entire program. I want to open another console window using os.system(xterm&) as a thread which works. The only thing is, is it possible to print to the new window while the other thread is printing to the older window?
import sys
import os
def my_fork():
child_pid = os.fork()
if child_pid == 0:
function=open('SMITH747.txt','r')
f=function.readlines()
fd = open("output", "w")
# Open xterm window with logs from that file
p = subprocess.Popen(["xterm", "-e", "tail", "-f", "output"])
# Do logging
while(True):
for i in range(1):
fd.write("Hello, world!")
time.sleep(2)
if f==[]:
pass
else:
bud=False
fd.flush()
else:
function=open('SMITH747.txt','w')
var=input('Enter ')
if var=='q':
function.write('yo')
if __name__ == "__main__":
my_fork()
this is what I have right now: It works except I can't get it to read my file and terminate if f is not []. I would appreciate it so much if someone can help me debug this part. Then it will be perfect!