ipc - Interactive Process Communication in Haskell -
i trying write haskell program executes interactive program (also written in haskell), sending , receiving lines of text. interactive program reads stdin , writes stdout using standard haskell library.
however, proved more complicated anticipated, due haskell lazyness or other misterious thing happening on background. program apparently goes deadlock, , not receive line of text expected receive. receive text fine if interactive program terminates result of sending line of text, need program keep running , receive more data (it's called interactive reason). prints expected output after kill program receiving message. code looks this:
main = (hin,hout,herr,pl) <- (runinteractivecommand "./playermain") hsetbinarymode hin false hsetbinarymode hout false hsetbuffering hin linebuffering hsetbuffering hout nobuffering hputstr hin "start\n" out <- hgetline hout putstrln out
i tried replacing lazy strings strict data.text, behaviour same. light?
maybe reason output of ./playermain
being buffered. ./playermain
writes doesn't flushed right away, , hangs because keeps expecting more input.
that explain why do message when program terminates.
so maybe work if modify ./playermain
, set stdout
nobuffering
.
Comments
Post a Comment