diff options
author | John Goerzen <jgoerzen@complete.org> | 2008-09-16 07:36:00 +0200 |
---|---|---|
committer | John Goerzen <jgoerzen@complete.org> | 2008-09-16 07:36:00 +0200 |
commit | 69cb7f23b65f42410b5463ac6b4d87985237b4eb (patch) | |
tree | 022058ca519ad0bbef9f2c8794c7731278a62a56 /Plugins/CommandReader.hs | |
parent | dacf87b9dfde0ae6083d4155627896638dc8741c (diff) | |
download | xmobar-69cb7f23b65f42410b5463ac6b4d87985237b4eb.tar.gz xmobar-69cb7f23b65f42410b5463ac6b4d87985237b4eb.tar.bz2 |
Cleaned up so that we watch the exit code
darcs-hash:20080916053600-c2a52-e068e71779dd9319a450127aeb7512350f0dcc56.gz
Diffstat (limited to 'Plugins/CommandReader.hs')
-rw-r--r-- | Plugins/CommandReader.hs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Plugins/CommandReader.hs b/Plugins/CommandReader.hs index fef8a45..eee23a6 100644 --- a/Plugins/CommandReader.hs +++ b/Plugins/CommandReader.hs @@ -17,7 +17,7 @@ module Plugins.CommandReader where import System.IO import Plugins -import System.Process(runInteractiveCommand) +import System.Process(runInteractiveCommand, getProcessExitCode) data CommandReader = CommandReader String String deriving (Read, Show) @@ -25,8 +25,15 @@ data CommandReader = CommandReader String String instance Exec CommandReader where alias (CommandReader _ a) = a start (CommandReader p _) cb = do - (hstdin, hstdout, hstderr, _) <- runInteractiveCommand p + (hstdin, hstdout, hstderr, ph) <- runInteractiveCommand p hClose hstdin hClose hstderr - forever (hGetLineSafe hstdout >>= cb) - where forever a = a >> forever a + hSetBinaryMode hstdout False + hSetBuffering hstdout LineBuffering + forever ph (hGetLineSafe hstdout >>= cb) + where forever ph a = + do a + ec <- getProcessExitCode ph + case ec of + Nothing -> forever ph a + Just _ -> cb "EXITED" |