1

have PyRun_InteractiveLoop() take input/output from/to another pty on linux

view story
linux-howto

http://stackoverflow.com – In a C program I want to run a Python interactive loop that takes its input from and makes its output to a pseudo terminal (for example pts/4) different than the one from which the C program was launched (for example pts/1). The basic way to run an interactive loop is: PyRun_InteractiveLoop(stdin, "<stdin>"); This however does not solve the problem because it uses the pseudo terminal from which the program was launched (pts/1), and not pts/4. A solution that works is: int fd = open("/dev/pts/4", O_RDWR); dup2(fd, 0); dup2(fd, 1); dup2(fd, 2); PyRun_InteractiveLoop(stdin, "<stdin (HowTos)