pygrub: Workaround for Solaris CR 1143256.
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 12 Mar 2009 10:58:21 +0000 (10:58 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 12 Mar 2009 10:58:21 +0000 (10:58 +0000)
The Solaris curses library has a broken timeout() function: after a
first timeout() call with a positive value for an argument, subsequent
calls will fail to reset it. So, getch() always times out, confusing
the pygrub timer in the main loop. Add an extra check to avoid exiting
prematurely.

Signed-off-by: Frank van der Linden <frank.vanderlinden@sun.com>
tools/pygrub/src/pygrub

index 0bd4578b9ecd664c2d0930065af9ed31f6397652..98b4352b85fbe93025ccd40de506d4837b087946 100644 (file)
@@ -441,7 +441,11 @@ class Grub:
                 # Timed out waiting for a keypress
                 if mytime != -1:
                     mytime += 1
-                    if mytime >= int(timeout):
+                    # curses.timeout() does not work properly on Solaris
+                    # So we may come here even after a key has been pressed.
+                    # Check both timeout and mytime to avoid exiting
+                    # when we shouldn't.
+                    if timeout != -1 and mytime >= int(timeout):
                         self.isdone = True
                         break
             else: