diff --git a/ZfsDevices.hs b/ZfsDevices.hs index 9fd257a..e26d24c 100644 --- a/ZfsDevices.hs +++ b/ZfsDevices.hs @@ -5,24 +5,9 @@ import System.Zfs.Zpool import System.Zfs.Types import System.Zfs import Control.Monad.IO.Class -import System.Process (createProcess, shell, waitForProcess, CreateProcess(..), StdStream(..)) -import System.IO (openTempFile, hClose, IOMode(WriteMode)) -import System.Directory (getTemporaryDirectory, removeFile) -import Control.Exception (bracket) +import System.Process (callCommand) +import Control.Concurrent (threadDelay) -callCommandSilently :: String -> IO () -callCommandSilently cmd = do - tempDir <- getTemporaryDirectory - let tempFile = tempDir ++ "/temp_output.log" - bracket - (openTempFile tempDir "temp_output.log") - (\(path, handle) -> hClose handle >> removeFile path) - (\(path, handle) -> do - let process = (shell cmd) { std_out = UseHandle handle, std_err = UseHandle handle } - (_, _, _, ph) <- createProcess process - waitForProcess ph - return () - ) main' :: Zfs () main' = do @@ -41,8 +26,9 @@ main' = do main :: IO () main = do - callCommandSilently "zpool import -a -N" -- detection, a ffi would be more elegant + callCommand "zpool import -a -N > /dev/null 2>&1" -- detection, a ffi would be more elegant + threadDelay (10 * 1000000) res <- runZfs main' case res of Left e -> print e - Right n -> return () + Right n -> return () \ No newline at end of file