Skip to content

Commit

Permalink
[1.3.X] Ensure stdin is a tty before handing it to termios, so as to …
Browse files Browse the repository at this point in the history
…prevent prolems when running under IDEs.

Backport of [15911] from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.3.X@16029 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
kmtracey committed Apr 17, 2011
1 parent 79bb9c1 commit cdd75e0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions django/utils/autoreload.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ def code_changed():

def ensure_echo_on():
if termios:
fd = sys.stdin.fileno()
attr_list = termios.tcgetattr(fd)
if not attr_list[3] & termios.ECHO:
attr_list[3] |= termios.ECHO
termios.tcsetattr(fd, termios.TCSANOW, attr_list)
fd = sys.stdin
if fd.isatty():
attr_list = termios.tcgetattr(fd)
if not attr_list[3] & termios.ECHO:
attr_list[3] |= termios.ECHO
termios.tcsetattr(fd, termios.TCSANOW, attr_list)

def reloader_thread():
ensure_echo_on()
Expand Down

0 comments on commit cdd75e0

Please sign in to comment.