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. <span></span><br><br>On Sunday, January 5, 2014, Andrew Gibiansky  wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello all,<div><br></div><div>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.</div>


<div><br></div><div>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.</div>


<div><br></div><div>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.</div><div><br></div><div>


-- Andrew</div></div>
</blockquote>