Hi all,<br><br>It&#39;s the first time I use the runInteractiveCommand and I was probably bitten by laziness.<br><br>When I run the following program and send its output to a file using &#39;&gt;&#39; redirection I get the full output of the called process. But if I run it in the console I get only half of the output. As console is slower than disk I assume the called process terminates before all data has been read from it or the main process terminates before data has been written to stdout. I thought using waitForProcess, closing called process output and flushing stdout would solve the problem but it doesn&#39;t.<br>
<br>&gt; -- Compile with -threaded option<br>&gt; module Main where<br>&gt; <br>&gt; import Control.Concurrent (forkIO)<br>&gt; import System.Environment (getArgs)<br>&gt; import System.FilePath (dropExtension, takeFileName)<br>
&gt; import System.IO (Handle, hClose, hFlush, hGetContents, stdout)<br>&gt; import System.Process (runInteractiveCommand, waitForProcess)<br>&gt; <br>&gt; main :: IO ()<br>&gt; main = do<br>&gt;&nbsp;&nbsp; (file:_) &lt;- getArgs<br>
&gt;&nbsp;&nbsp; (_, out, _, pid) &lt;- runInteractiveCommand $ &quot;dumpbin /EXPORTS &quot; ++ file<br>&gt;&nbsp;&nbsp; forkIO (createDefFile file out)<br>&gt;&nbsp;&nbsp; waitForProcess pid<br>&gt;&nbsp;&nbsp; hClose out<br>&gt;&nbsp;&nbsp; hFlush stdout<br>&gt; <br>&gt; createDefFile :: String -&gt; Handle -&gt; IO ()<br>
&gt; createDefFile file inp = do<br>&gt;&nbsp;&nbsp; putStrLn $ &quot;LIBRARY &quot; ++ (dropExtension . takeFileName) file ++ &quot;.dll&quot;<br>&gt;&nbsp;&nbsp; putStrLn &quot;EXPORTS&quot;<br>&gt;&nbsp;&nbsp; text &lt;- hGetContents inp<br>&gt;&nbsp;&nbsp; mapM_ writeExport $ keepExports $ map words $ lines text<br>
&gt;&nbsp;&nbsp; where<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; keepExports :: [[String]] -&gt; [String]<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; keepExports = map head<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . filter (not . null)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . takeWhile ([&quot;Summary&quot;]/=)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . drop 1<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . dropWhile ([&quot;ordinal&quot;,&quot;name&quot;]/=)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; writeExport (&#39;_&#39;:xs) = putStrLn xs<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; writeExport xs = putStrLn xs<br><br>Any idea regarding the cause of this problem?<br>

<br>
Thanks,<br>
<br>
Olivier.<br>
<br>