[Haskell-cafe] Intercept stdin in Haskell
carter.schonwald at gmail.com
Sun Jan 5 19:12:46 UTC 2014
What's the motivation / use case? You could alternatively do the
redirection from launching the program from shell if you can't midify the
Haskell code yourself.
On Sunday, January 5, 2014, Andrew Gibiansky wrote:
> 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...
More information about the Haskell-Cafe