rnons <remotenonse...@gmail.com> writes: [...]
> mpgLoop = do > let sh = "mpg123 -R" > (Just hin, Just hout, _, hdl) <- createProcess (shell sh){ std_in = > CreatePipe, std_out=CreatePipe } > --hPutStrLn hin "SILENCE" > hPutStrLn hin "LOAD /home/rnons/Music/test.mp3" > hFlush hin > waitForProcess hdl > return () [...] > I expected with "waitForProcess", this program will be able to run > till the song ends. However, mpg123 plays for only 6 seconds. > > Maybe I missed something? Just a guess: the problem may be that "a Handle will be automatically closed when the garbage collector detects that it has become unreferenced by the program"[1], and in the program above, the liveness of the hin/hout references ends before mpg123 is finished playing. And 'mpg123 -R' shuts down as soon as it detects its stdin (or stdout) getting EOF... so that's what you're experiencing most likely here. Try to keep hin/hout "alive" a bit longer, and mpg123 should survive longer. Also you should most probably consume the output comming from 'mpg123 -R' via 'hout', as otherwise it the buffer might build up and mpg123 might block. hth, hvr [1]: http://hackage.haskell.org/packages/archive/base/4.6.0.0/doc/html/System-IO.html#t:Handle _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe