--- /Python-3.5.2/Lib/pty.py 2016-06-25 23:38:36.000000000 +0200 +++ pty.py 2016-12-23 14:47:19.229571369 +0100 @@ -144,6 +144,11 @@ data = stdin_read(STDIN_FILENO) if not data: fds.remove(STDIN_FILENO) + # STDIN is gone. When having attached this to a `nc -e` and the + # client disconnects, we want to make sure that we will not + # leave a process hanging around forever but we want to + # terminate at some point. This is basically a broken pipe. + return else: _writen(master_fd, data) @@ -154,6 +159,7 @@ pid, master_fd = fork() if pid == CHILD: os.execlp(argv[0], *argv) + assert False, "unreachable or exec failed" try: mode = tty.tcgetattr(STDIN_FILENO) tty.setraw(STDIN_FILENO)