[Haskell-cafe] Intercept stdin in Haskell

Andrew Gibiansky andrew.gibiansky at gmail.com
Sun Jan 5 17:46:07 UTC 2014


Hello all,

I need to do something strange and terrible in Haskell: intercept `stdin`.
In other words, I need to detect (in another thread, probably?) when my
running program is trying to read from `stdin`, and then feed it some data.

I know I can use `hDupTo` and other similar things to replace the stdin
handle with my own handle, and I know I could probably use `createPipe` or
similar from the `unix` package in order to write things to these handles,
but I have no idea how I might go about detecting that a handle is being
read from.

Any ideas? I've racked my brain and cannot come up with a way to do this. I
am using the GHC API elsewhere if that leads to any sort of crazy hackery
that might save the day.

-- Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140105/323fd7c4/attachment.html>


More information about the Haskell-Cafe mailing list