Bug #198491 - Disable termios.OPOST post-processing of output on
authorZac Medico <zmedico@gentoo.org>
Tue, 20 Nov 2007 20:05:12 +0000 (20:05 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 20 Nov 2007 20:05:12 +0000 (20:05 -0000)
the slave pty file descriptor since otherwise weird things like
\n -> \r\n transformations may occur. Thanks to Ulrich Mueller
<ulm@gentoo.org> for this patch. (trunk r8473)

svn path=/main/branches/2.1.2/; revision=8550

pym/portage.py

index 254ae0b1a5717ce1848bac7d3a6a56cd0022a82b..e25c856781198fffd2645d40960f7bdf37b238fb 100644 (file)
@@ -2567,6 +2567,13 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero
                                writemsg("openpty failed: '%s'\n" % str(e), noiselevel=1)
                                del e
                                master_fd, slave_fd = os.pipe()
+               if got_pty:
+                       # Disable post-processing of output since otherwise weird
+                       # things like \n -> \r\n transformations may occur.
+                       import termios
+                       mode = termios.tcgetattr(slave_fd)
+                       mode[1] &= ~termios.OPOST
+                       termios.tcsetattr(slave_fd, termios.TCSANOW, mode)
 
                # We must set non-blocking mode before we close the slave_fd
                # since otherwise the fcntl call can fail on FreeBSD (the child