For pty logging, handle the EAGAIN error that is thrown from fcntl when the slave...
authorZac Medico <zmedico@gentoo.org>
Sun, 29 Jul 2007 02:10:36 +0000 (02:10 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 29 Jul 2007 02:10:36 +0000 (02:10 -0000)
svn path=/main/branches/2.1.2/; revision=7425

pym/portage.py

index 1b97fa8556a044ea3aeca339bb3665f390395158..2cd342e5a97fe63c6b23580d6e745d7e4f5f1c9d 100644 (file)
@@ -2420,8 +2420,16 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero
                        for f in events[0]:
                                # Use non-blocking mode to prevent read
                                # calls from blocking indefinitely.
-                               fcntl.fcntl(f.fileno(), fcntl.F_SETFL,
-                                       fd_flags[f] | os.O_NONBLOCK)
+                               try:
+                                       fcntl.fcntl(f.fileno(), fcntl.F_SETFL,
+                                               fd_flags[f] | os.O_NONBLOCK)
+                               except EnvironmentError, e:
+                                       if e.errno != errno.EAGAIN:
+                                               raise
+                                       del e
+                                       # The EAGAIN error signals eof on FreeBSD.
+                                       eof = True
+                                       break
                                buf = array.array('B')
                                try:
                                        buf.fromfile(f, buffsize)