ENH use better types for wait
This commit is contained in:
parent
c13de68d4f
commit
7e9d7d6d4b
|
@ -21,6 +21,7 @@ import RIO
|
||||||
import RIO.Process
|
import RIO.Process
|
||||||
import qualified RIO.Text as T
|
import qualified RIO.Text as T
|
||||||
import System.Environment
|
import System.Environment
|
||||||
|
import System.Process (Pid)
|
||||||
import Text.XML.Light
|
import Text.XML.Light
|
||||||
import XMonad.Internal.Concurrent.VirtualBox
|
import XMonad.Internal.Concurrent.VirtualBox
|
||||||
import XMonad.Internal.IO
|
import XMonad.Internal.IO
|
||||||
|
@ -54,7 +55,7 @@ vmLaunch i = do
|
||||||
"Failed to start VM: "
|
"Failed to start VM: "
|
||||||
<> displayBytesUtf8 (encodeUtf8 i)
|
<> displayBytesUtf8 (encodeUtf8 i)
|
||||||
|
|
||||||
vmPID :: T.Text -> RIO SimpleApp (Maybe Int)
|
vmPID :: T.Text -> RIO SimpleApp (Maybe Pid)
|
||||||
vmPID vid = do
|
vmPID vid = do
|
||||||
(rc, out) <- proc "pgrep" ["-f", "VirtualBoxVM.*" ++ T.unpack vid] readProcessStdout
|
(rc, out) <- proc "pgrep" ["-f", "VirtualBoxVM.*" ++ T.unpack vid] readProcessStdout
|
||||||
return $ case rc of
|
return $ case rc of
|
||||||
|
|
|
@ -31,6 +31,7 @@ import RIO.Directory
|
||||||
import RIO.FilePath
|
import RIO.FilePath
|
||||||
import qualified RIO.Text as T
|
import qualified RIO.Text as T
|
||||||
import System.IO.Error
|
import System.IO.Error
|
||||||
|
import System.Process
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- read
|
-- read
|
||||||
|
@ -161,7 +162,7 @@ getPermissionsSafe f = do
|
||||||
-- | Block until a PID has exited.
|
-- | Block until a PID has exited.
|
||||||
-- Use this to control flow based on a process that was not explicitly started
|
-- Use this to control flow based on a process that was not explicitly started
|
||||||
-- by the Haskell runtime itself, and thus has no data structures to query.
|
-- by the Haskell runtime itself, and thus has no data structures to query.
|
||||||
waitUntilExit :: (MonadIO m, Show t, Num t) => t -> m ()
|
waitUntilExit :: (MonadIO m) => Pid -> m ()
|
||||||
waitUntilExit pid = do
|
waitUntilExit pid = do
|
||||||
res <- doesDirectoryExist $ "/proc" </> show pid
|
res <- doesDirectoryExist $ "/proc" </> show pid
|
||||||
when res $ do
|
when res $ do
|
||||||
|
|
Loading…
Reference in New Issue