diff options
-rw-r--r-- | debug-me.hs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/debug-me.hs b/debug-me.hs index 6103545..69870f1 100644 --- a/debug-me.hs +++ b/debug-me.hs @@ -4,7 +4,9 @@ import Types import Hash import Pty +import Control.Concurrent import Control.Concurrent.Async +import Control.Concurrent.STM import System.IO import System.Process import System.Exit @@ -23,21 +25,22 @@ main = do let Master h = ptyMaster p hSetBuffering stdin NoBuffering hSetBuffering h NoBuffering - ithread <- async (forward stdin h ph) - othread <- async (forward h stdout ph) + ithread <- async (forward stdin h ph 200000) + othread <- async (forward h stdout ph 0) exitstatus <- waitForProcess ph cancel ithread cancel othread return exitstatus -forward :: Handle -> Handle -> ProcessHandle -> IO () -forward from to ph = do +forward :: Handle -> Handle -> ProcessHandle -> Int -> IO () +forward from to ph delay = do b <- B.hGetSome from 1024 if b == B.empty then do terminateProcess ph return () else do + threadDelay delay B.hPut to b hFlush to - forward from to ph + forward from to ph delay |