[Haskell-cafe] How to waitForProcess?

Magicloud Magiclouds magicloud.magiclouds at gmail.com
Wed Sep 5 06:45:10 CEST 2012


Forgot about that, just read 'readProcess' code to figure out.
Thanks.

On Wed, Sep 5, 2012 at 12:37 PM, Ivan Lazar Miljenovic
<ivan.miljenovic at gmail.com> wrote:
> On 5 September 2012 13:45, Magicloud Magiclouds
> <magicloud.magiclouds at gmail.com> wrote:
>> Hi,
>>   I have code like this and it leaves lots of zombies of flow-export.
>> Then I add waitForProcess.... Well I do not know where to put it.
>> Before or after 'hGetContents' both make the program hung.
>
> You're probably being bitten by hGetContents being lazy.  Force the
> result of hGetContents (e.g. `evaluate . length =<< hGetContents o ')
> and then use waitForProcess.
>
>>
>> exportCSV :: FilePath -> IO [String]
>> exportCSV file = do
>>   csv_ <- withBinaryFile file ReadMode $ \i -> do
>>     (_, Just o, _, h) <- createProcess $ CreateProcess (RawCommand
>> "/usr/bin/flow-export" ["-f2"]) Nothing Nothing (UseHandle i)
>> CreatePipe Inherit True False
>>     hGetContents o
>>   return $ tail $ lines csv_
>>
>> --
>> 竹密岂妨流水过
>> 山高哪阻野云飞
>>
>> And for G+, please use magiclouds#gmail.com.
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
>
> --
> Ivan Lazar Miljenovic
> Ivan.Miljenovic at gmail.com
> http://IvanMiljenovic.wordpress.com



-- 
竹密岂妨流水过
山高哪阻野云飞

And for G+, please use magiclouds#gmail.com.



More information about the Haskell-Cafe mailing list