import subprocess
process = subprocess.Popen(['bash', '-i'], stdout=subprocess.PIPE, stdin=
    subprocess.PIPE)
process.stdin.write('exit\n')
process.wait()
loop over a batch script that does not terminate