libc = ctypes.CDLL('libc.so.6')
master, slave = pty.openpty()
p = subprocess.Popen(['/bin/bash', '-i'], preexec_fn=libc.setsid, stdin=
    slave, stdout=slave, stderr=slave)
Run interactive Bash with popen and a dedicated TTY Python