I've got a small pexpect-based program that launches a Python REPL, puts it into an infinite loop that prints something on each iteration, and - after a short time - sends a control-c to kill the loop ...