Author Cornelius Diekmann
Recipients Cornelius Diekmann, martin.panter
Date 2016-12-23.14:17:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
My OS: Debian GNU/Linux 8.6 (jessie)
Python 3.4.2 from Python-3.5.2/Lib ( is just a tiny, portable python file which did not see many changes)

Bug Report

Steps to Reproduce:

I wrote a very simple python remote shell:

#!/usr/bin/env python3
import pty

It can be run in a terminal (call it TermA) with `nc -e ./ -l -p 6699`
In a different terminal (call it TermB), I connect to my fancy remote shell with `nc 6699`.
The shell works fine. In TermB, I quit by pressing ctrl+c.

Observed Behavior: In TermA, the nc process, the python process, and the spawned /bin/sh still exist. They still occupy TermA.

Expected Behavior: The client in TermB has disconnected, /bin/sh in TermA can no longer read anything from stdin and it should close down. Ultimately, in TermA, nc should have exited successfully.

Fix: End the _copy loop in once EOF in STDIN is reached. Everything shuts itself down automatically. I included a small patch to demonstrate this behavior.

This patch is not meant to go straight into production. I have not verified if this behavior somehow breaks other use cases. This bug report is meant to document exactly one specific use case and supply exactly one line of code change for it.

This issue is related to issue26228. Actually, it is complementary. issue26228 wants to return if master_fd is EOF, this issue wants to return if stdin is EOF. Both behaviors together looks good to me. By the way, I hacked a hacky `assert False` into my patch as a placeholder for issue26228's proper handling of exec failures at that part of the code.

I suggest to combine the patches of this issue and issue26228.
Date User Action Args
2016-12-23 14:17:17Cornelius Diekmannsetrecipients: + Cornelius Diekmann, martin.panter
2016-12-23 14:17:17Cornelius Diekmannsetmessageid: <>
2016-12-23 14:17:17Cornelius Diekmannlinkissue29054 messages
2016-12-23 14:17:16Cornelius Diekmanncreate