- catchWhenTrue :: IORef Bool -> IO () -> IO ()
- catchWhenTrue exitOk a =
- a `catch` (\e -> do
- x <- readIORef exitOk
- unless x $ throw (e :: SomeException))
-
- -- | Listens to the server output, makes sure it matches the record and
- -- signals any semaphores
- -- Note that on Windows, we cannot kill a thread stuck in getNextMessage.
- -- So we have to wait for the exit notification to kill the process first
- -- and then getNextMessage will fail.
+ -- | Asks the server to shutdown and exit politely
+ exitServer :: Session ()
+ exitServer = request_ Shutdown (Nothing :: Maybe Value) >> sendNotification Exit ExitParams
+
+ -- | Listens to the server output until the shutdown ack,
+ -- makes sure it matches the record and signals any semaphores