A small correction: when I referred to text appearing in my terminal in (1), the message is actually (for example): Connection to github.com closed by remote host. On Tue, Jan 14, 2014 at 5:42 PM, Caleb Spare <cespare at gmail.com> wrote: > I use ControlMaster auto (along with ControlPath) in my ssh config and > find it very handy. > > I have noticed an annoying behavior, though: it seems that if there is > no existing master connection and ssh creates a new one, the master > connection process that is started has its stderr left open. > > This has manifested itself in two ways so far: > > (1) When using ssh day-to-day, I may be doing some work and the text > 'Shared connection to [servername] closed.' appears in my terminal. > This happens when the remote server closes the connection after some > amount of time (maybe hours or days). It's disruptive; I don't care > about that connection and ssh will transparently open a new one the > next time I ssh in. The text might appear while I'm inside vim or top > and mess with that program. > > (2) Some software (I noticed it with Ansible[1]) waits for > stderr/stdout of a process to be closed. In the case of Ansible it was > because the communicate() method of Python's subprocess module[2] > waits on stdout/stderr as well as wait()ing on the process itself. > (This behavior seems strange to me, but it's indicative that openssh's > behavior here is atypical, I think.) > > I haven't looked at the code yet, but I think the behavior I'd expect > would be that when ssh creates the controlmaster process, it would set > its stdin/stderr/stdout to /dev/null, or else some logfile. It's not > useful to have that process writing to the terminal after its parent > is long dead. > > Thanks for any information/feedback you can provide! > -Caleb > > [1] http://www.ansibleworks.com/ > [2] http://docs.python.org/2/library/subprocess.html#subprocess.Popen.communicate