diff --git a/System/Console/Haskeline/Backend/Posix.hsc b/System/Console/Haskeline/Backend/Posix.hsc
--- a/System/Console/Haskeline/Backend/Posix.hsc
+++ b/System/Console/Haskeline/Backend/Posix.hsc
@@ -36,6 +36,9 @@
 import GHC.IOBase (haFD,FD)
 import GHC.Handle (withHandle_)
 
+#ifdef USE_TERMIOS_H
+#include <termios.h>
+#endif
 #include <sys/ioctl.h>
 
 -------------------
@@ -293,9 +296,6 @@
                                 }
 
 bracketSet :: (Eq a, MonadException m) => IO a -> (a -> IO ()) -> a -> m b -> m b
-bracketSet getState set newState f = do
-    oldState <- liftIO getState
-    if oldState == newState
-        then f
-        else finally (liftIO (set newState) >> f) (liftIO (set oldState))
-
+bracketSet getState set newState f = bracket (liftIO getState)
+                            (liftIO . set)
+                            (\_ -> liftIO (set newState) >> f)
diff --git a/haskeline.cabal b/haskeline.cabal
--- a/haskeline.cabal
+++ b/haskeline.cabal
@@ -1,6 +1,6 @@
 Name:           haskeline
 Cabal-Version:  >=1.6
-Version:        0.6.1.1
+Version:        0.6.1.2
 Category:       User Interfaces
 License:        BSD3
 License-File:   LICENSE
@@ -100,6 +100,9 @@
             Build-depends: terminfo==0.3.*
             Other-modules: System.Console.Haskeline.Backend.Terminfo
             cpp-options: -DTERMINFO
+        }
+        if os(solaris) {
+            cpp-options: -DUSE_TERMIOS_H
         }
     }
     ghc-options: -Wall
