[Haskell-cafe] haskell and releasing resources
fmohamed at mac.com
Tue Feb 6 09:12:59 EST 2007
> Wait for the process to terminate, using
> waitForProcess pid
Thanks fro the prompt response Don, I should have said it, but I knew
about waitForProcess pid but I did not want to use it.
The reason is the following, if I do
getTextOfPdf pdfPath = do
(inp,out,err,pid) <- runInteractiveCommand ("pdftotext -l 1 "+
return (hGetContents out)
it deadlocks, because I did not read out yet, and if the buffer is
full then the process sleeps waiting for me to read.
So I can forkIO the wait, but then the question is do I have to wait
for the thread?
Giving back the pid along with out is a solution, but I did not want
to caller to know about the detail that I am using an external
process to get the data.
Also I did not want to read everything in memory, as I think you do
in your example, ok I could, but why should I, we are lazy right?...
More information about the Haskell-Cafe