[New-bugs-announce] [issue22662] subprocess.Popen.communicate causing local tty terminal settings to change inconsistently

Kyle report at bugs.python.org
Fri Oct 17 22:44:33 CEST 2014


New submission from Kyle:

I'm not sure if this is a bash or Python issue.  I'm trying to run a command on a remote server, using the subprocess module.  I call ssh inside of subprocess.Popen(...).communicate(), like so:

output = subprocess.Popen(["/bin/env %s /usr/bin/ssh -ttt %s@%s -- %s;" % (env, user, host, command)], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).communicate()

Following the call to communicate(), my terminal settings are changed.  However, it's not always repeatable.  Sometimes it happens, and other times it does not.  When it does happen, I've noticed that the following tty options are ON prior to the command executing, and OFF afterwards (output from stty -a):
icrnl opost isig icanon echo echoe echok

Something with the communicate() call seems to cause the issue.  I don't actually have to print anything to the screen from Python for it to occur.

The problem goes away if I remove the "-t" option to ssh, however, I'm passing through the TERM environmental variable, and need -t to be set.  Because of this, I'm not sure if the problem is with the Python call, or something within Bash.

I've been able to repeat this on Ubuntu 13.10 running Python 2.7.5, and on Red Hat 6.4 running Python 2.6.6.

----------
messages: 229602
nosy: kflavin
priority: normal
severity: normal
status: open
title: subprocess.Popen.communicate causing local tty terminal settings to change inconsistently
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22662>
_______________________________________


More information about the New-bugs-announce mailing list